I'm redirecting this URL:
http://mydomain.com/expandyourtaste
Using this .htaccess file:
#Expand your tastes redirects
Redirect 301 /expandyourtaste http://mydomain.com/mobile
Redirect 301 /expandyourtaste/tastyextras http://mydomain.com/mobile/tasty_extras
Redirect 301 /expandyourtaste/coffee http://mydomain.com/mobile/coffe
Redirect 301 /expandyourtaste/400Calorie http://mydomain.com/mobile/400calories
Redirect 301 /expandyourtaste/Kidsstuff http://mydomain.com/mobile/kids_stuff
Redirect 301 /pickyourpasta http://mydomain.com/mobile/pickyourpasta
Redirect 301 /newpastaentrees http://mydomain.com/mobile/newpasta
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
#Expression Engine
# I BELIEVE THE ISSUE LIES HERE
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
AcceptPathInfo On
</IfModule>
# enable gzip compression
<FilesMatch "\.(js|css|php)$">
SetOutputFilter DEFLATE
</FilesMatch>
<IfModule mod_headers.c>
Header unset ETag
FileETag None
</IfModule>
<FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
<FilesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
Header unset Last-Modified
</FilesMatch>
# force download pdfs
AddType application/force-download .pdf
#Increase File Upload Size
php_value upload_max_filesize 20M
php_value post_max_size 20M
The issue is that when the URL is redirected, is ends up like this:
http://mydomain.com/mobile?/expandyourtaste
I think I have narrowed down the issue to the marked section in the code. Do you see the issue?
What happens if you convert your Redirect
statements to RewriteRule
? mod_rewrite
executes before mod_alias
, regardless of the order in your .htaccess
. Mixing the two can cause weirdness.
Edit:
Take a look at http://my.opera.com/GreyWyvern/blog/2007/09/12/apache-mod-rewrite for more info