Jump to content

Url Rewriting Using Mod_rewrite Does Not Work


Recommended Posts

Apache/2.0.52 (Red Hat)PHP Version 5.2.9phpinfo()Zend Engine v2.2.0Loaded Modules - mod_rewrite (one of many).url_rewriter.tags a=href,area=href,frame=src,input=src,form=,fieldset= a=href,area=href,frame=src,input=src,form=,fieldset=When I enable URL Rewriting using mod_rewrite in the html_public directory everything works great.In the past when I added additional web sites, I added them in subdirectories. Even though I had a robots.txt and each subdirectories has a domain assigned to it the search engines still see it as a subdirectory and then do not list the site.When I moved the sites to a higher directory (out of public view) and assign the domain to it everything works except mod_rewrite.Does anyone know how to fix this? Do I edit httpd.conf? Do I edit php.ini? Any help would be greatly appreciated..htaccess file

RewriteEngine onRewriteBase /RewriteRule ^manager(/.*)?$ - [NC,L]RewriteRule ^privacy.html$ index.php?page=privacyRewriteRule ^terms_of_use.html$ index.php?page=terms_of_useRewriteRule ^services.html$ index.php?page=servicesRewriteRule ^faq.html$ index.php?page=faqRewriteRule ^stories.html$ index.php?page=storiesRewriteRule ^story([^/]+).htm$ index.php?page=showstory&storyid=$1RewriteRule ^articles.html$ index.php?page=articlesRewriteRule ^article([^/]+).htm$ index.php?page=showarticle&articleid=$1RewriteRule ^news([^/]+).htm$ index.php?page=shownews&newsid=$1RewriteRule ^allnews.html$ index.php?page=allnewsRewriteRule ^([a-zA-Z0-9_-]+)$ showprofile.php?username=$1RewriteRule ^([^/]+).htm$ showprofile.php?id=$1

Link to comment
Share on other sites

Did you move the htaccess file into the new directories also?
I have added .htaccess files to all of the domains I have created, the only places it works is in the root directory. Example: /dir1/dir2/html/If I create domains below this in a sub-directory (Example: /dir1/dir2/html/anotherSite/) then the mod_rewrite works, however, the domain is also seen by search engines as a sub-directory of the main site and they will not list it.I have been creating my new domains in a parallel directory (Example: /dir1/dir2/anotherSite/) and the search engines see them as an individual site (not a subdir), however, mod_rewrite stops working.The .htaccess file in the root directory is for a Joomla site and it works great.The following statement is in the httpd.conf file
## DocumentRoot: The directory out of which you will serve your# documents. By default, all requests are taken from this directory, but# symbolic links and aliases may be used to point to other locations.#DocumentRoot /var/www/html

Can anyone tell me how to do this?

Edited by Vern Southern
Link to comment
Share on other sites

Solution http://forums.westhost.com/showthread.php?p=45980#post45980wildjokerdesign__________________________________________________You need to edit your httpd.conf. You don't want to change your DocumentRoot really but you do want to look at this:

<Directory "/var/www/html">	Options FollowSymLinks MultiViews Includes ExecCGI	AddHandler cgi-script .cgi .pl .py .sh	AllowOverride All	Order allow,deny	Allow from all</Directory>

This is the code that makes the "magic" happen on your main domain. Any of those directives can be used in Directory tags for or additional domains. They can be added below that one or down in the VirtualHost tags for each domain. Here is an example based on what you posted:

<Directory "/var/www/newsite">	Options FollowSymLinks MultiViews Includes ExecCGI	AddHandler cgi-script .cgi .pl .py .sh	AllowOverride All	Order allow,deny	Allow from all</Directory>

You don't technically need all the directives but I just use the main domains set up for ease. __________________________________________________My reply to wildjokerdesignI copied your example to my httpd.conf file and uploaded it. It did not work at first but then I remembered to restart the Apache server and everything worked perfect. Also to any newbee's who may be reading this. Dump your browser cache and cookies.Thanks for your help. I am very grateful. This will help my standing in Google and other search engines.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...