Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

mod_rewrite not redirecting!

RewriteEngine On
RewriteRule   ^/automobiles(/)$             /index.php?view=autos             [R=301,NC,QSA,L]

This should take http://www.example.com/automobiles and point it to http://www.example.com/index.php?view=autos, no?
0
trickyidiot
Asked:
trickyidiot
  • 3
  • 2
1 Solution
 
caterham_wwwCommented:
in httpd.conf
RewriteEngine On
RewriteRule   ^/automobiles/?$             /index.php?view=autos             [R=301,NC,QSA,L]

or in .htaccess files:

RewriteEngine On
RewriteRule   ^automobiles/?$             /index.php?view=autos             [R=301,NC,QSA,L]



/? stands for 0 or 1 slash. If you don't want an external redirect, drop "R=301," from the flags

0
 
trickyidiotAuthor Commented:
Got a big fat internal server error on that one

here's the full set of code from httpd.conf:
<Directory />
    Options FollowSymLinks
    AllowOverride All
		<IfModule mod_rewrite.c>
			RewriteEngine On
			RewriteCond   %{REQUEST_FILENAME} !-f
			RewriteCond   %{REQUEST_FILENAME} !-d
			#RewriteRule   ^/automobiles/?$ 			/index.php?view=autos 		[NC,L]
			#RewriteRule   ^/computing/?$ 				/index.php?categoryID=2953 	[NC,L]
			#RewriteRule   ^/electronics/?$ 			/index.php?categoryID=2721 	[NC,L]
			#RewriteRule   ^/mac/?$ 					/index.php?categoryID=2720 	[NC,L]
			#RewriteRule   ^/memory/?$ 					/index.php?categoryID=5013 	[NC,L]
			#RewriteRule   ^/mobilecomputing/?$ 		/index.php?categoryID=2719 	[NC,L]
			#RewriteRule   ^/officesupplies/?$ 			/index.php?categoryID=3816 	[NC,L]
			#RewriteRule   ^/traveler/?$ 				/index.php?view=traveler 	[NC,L]
			RewriteRule   ^(.*)$ /index.php?action=OldLinkConversion&queryString=$1 [QSA,L]
		</IfModule>
</Directory>

Open in new window

0
 
trickyidiotAuthor Commented:
I have the rules commented out as they caused the internal server error
0
 
caterham_wwwCommented:
That is directory context. I'd suggest - if possible - to place the rules outside of the <Directory> section with (code below). That would avoid internal redirects.

The rules are/were not the origin of the problem, but the conditions are on a wrong place. The order of processing is always rule-pattern --> condition(s) --> substitution. So the conditions above a rule are only applied for this specific rule, not for all rules below.
                        RewriteEngine On
                        RewriteRule   ^/automobiles/?$                         /index.php?view=autos           [NC,L]
                        RewriteRule   ^/computing/?$                           /index.php?categoryID=2953      [NC,L]
                        RewriteRule   ^/electronics/?$                         /index.php?categoryID=2721      [NC,L]
                        RewriteRule   ^/mac/?$                                         /index.php?categoryID=2720      [NC,L]
                        RewriteRule   ^/memory/?$                                      /index.php?categoryID=5013      [NC,L]
                        RewriteRule   ^/mobilecomputing/?$             /index.php?categoryID=2719      [NC,L]
                        RewriteRule   ^/officesupplies/?$                      /index.php?categoryID=3816      [NC,L]
                        RewriteRule   ^/traveler/?$                            /index.php?view=traveler        [NC,L]
                        RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
                        RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
                        RewriteRule   ^(.*)$ /index.php?action=OldLinkConversion&queryString=$1 [QSA,L]

Open in new window

0
 
trickyidiotAuthor Commented:
nail, head, some smashing involved - good carpenter.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now