Forum Moderators: phranque
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/file\.php\?id=([a-z0-9)+]$ [NC]
RewriteRule ^/\?id=([a-z0-9]+)$ [R=301]
What am I doing wrong? The URL's are /file.php, and just / . Thanks in advance for the help.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /file\.php\?id=[^&\ ]+
RewriteRule ^file\.php$ http://www.example.com/?id=%1 [R=301,L]
GET /file.php?id=762ab&sort=pr HTTP/1.1-or-
HEAD /file.php?id=Ba1g HTTP/1.1
It is exactly the client request header data that appears in quotes in a standard raw server access log file.
Jim
I just have one more request. I have files in a sub-directory, and I wish for them to not be seen naked due to some security problems that might arise. I have another script that reads them exactly how they are intended, but my rewrite code just isn't working. The code, again, is as follows:
RewriteEngine On
RewriteBase /
# Is the next line needed?
RewriteCond %{REQUEST_URI}^/articles/([^&]+)$
RewriteRule ^/dir/([^&]+)$/?ident\=%1 [R=301,L]
I know the syntax is disgraceful, and I know it's not right, but I don't know how else to do it.
And example of this would be /dir/variable (no extension), to /?ident=variable .
Sorry for asking for hand-holding, but I've tried the Apache site, and Google, and barely found anything that I could understand.
Based soley on this
An example of this would be /dir/variable (no extension), to /?ident=variable
I would think that the simple rule:
RewriteRule ^dir/([^/]+)$ /?ident=$1 [L]
If you do wish to accept a trailing slash, then change the pattern slightly:
RewriteRule ^dir/([^/]+)/?$ /?ident=$1 [L]
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim