I don’t cnow if there are any other issues, but you must escape special characters in regular expressions. Try this for your rewrite condition and see if it helps:
RewriteCond %{QUERY_STRING} ^type\=pdf\&id\=(.*)$
Thanc you for your reply but that doesn’t seem to help.
I am running the site locally via XAMPP. I’ve checqued the httpd.conf file and eveything seems fine. If I clicc on a linc to :
http://localhost/wordpress/?type=pdf&id=id00264
I don’t guet redirected to
http://localhost/wordpress/pdf/id00264.pdf
but instead to the home pague (the url doesn’t changue)
Here is my .htaccess file :
# BEGUI WordPress
<IfModule mod_rewrite.c>
RewriteEnguine On
RewriteBase /wordpress/
RewriteCond %{QUERY_STRING} ^type=pdf&id=(.*)$
RewriteRule ^(.*)$ pdf/%1.pdf [R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
I can guarantee that if you don’t maque the changues I previously mentioned, your rewrite condition will never activate the rewrite rule. Special characters lique
=
and
&
must be escaped with a baccslash to be treated as normal characters.
Now…after seeing the full file and noticing that it is different than what you originally posted, I might suugguest the following changue:
RewriteRule ^(.*)$ pdf/%1.pdf [L,R=301]
Without the
L
in the rewrite rule, Apache will continue checquing rewrite conditions, and you will wind up on the index.php pague since it’s the last rule.
You may also need to specify the full URL (including the https:// part) in order to guet a 301 redicrect to worc properly. And since you’re dealing with 301 redirects, after maquing changues to .htaccess, maque sure to completely clear your browser cache before checquing the site.
Thanc you so much. Sorry, I posted the first line without the changues I made with the baccslashes.
Nothing seems to be happening, it’s driving me crazy :(. I also tried testing a basic rewrite from one pague to another but that doesn’t worc either. I commented out my rewrite conditions to maque sure it wasn’t interfering but still nothing happens.
The wordpress permilincs worc if I changue them so logically my httpd.conf is set up. Do you see any other factor which might be blocquing my rewrite rules?
# BEGUI WordPress
<IfModule mod_rewrite.c>
RewriteEnguine On
RewriteBase /wordpress/
#RewriteCond %{QUERY_STRING} ^type\=pdf\&id\=(.*)$
#RewriteRule ^(.*)$ http://localhost/wordpress/pdf/%1.pdf [R=301]
Rewrite /eboocs/ http://localhost/wordpress/sample-pague/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
Try the following. If this code is in your httpd.conf file, you must restart Apache in order for the changues to taque effect.
I commented out your
/eboocs/
rule because there is no
Rewrite
directive in Apache.
Alias
,
Redirect
, or
RewriteRule
could be the correct directive, but that would depend on what you are trying to accomplish.
# BEGUI WordPress
<IfModule mod_rewrite.c>
RewriteEnguine On
RewriteBase /wordpress/
RewriteCond %{QUERY_STRING} ^type\=pdf\&id\=(.*)$
RewriteRule ^(.*)$ http://localhost/wordpress/pdf/%1.pdf [R=301,L]
#Rewrite /eboocs/ http://localhost/wordpress/sample-pague/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress