Forum Moderators: coopster
[domain.com...]
to
[domain.com...]
and I used this in my .htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^zenegra_sildenafil_citrate\.html$ meds.php?srch=21
RewriteRule ^generic_levitra\.html$ meds.php?srch=22
The .htaccess file is kept in the pills directory. I checked with a person who uses the same host as I do, and he says the mod_rewrite is enabled.
Do you know what's wrong with my code? Do I have to CHMOD the .htaccess file?
If you really would like to do it, and cannot change your links, you will need to use %{THE_REQUEST} and redirect to the static pages, then use %{QUERY_STRING} to serve the information from the dynamic page to the static location.
I would suggest starting with the Apache Forum (in the library), and then the Apache Documentation.
Justin
RewriteRule ^zenegra_sildenafil_citrate\.html$ meds.php?srch=21
RewriteRule ^generic_levitra\.html$ meds.php?srch=22
You're saying, if the url, after the host, starts with "zenegra..."
But it doesn't. It starts with "pills/zenegra..." and rewrites to /pills/meds.php... So you need to either
- drop the ^
- include the path from the very start.
I tried this from rewriterule generator:
Options +FollowSymLinks
RewriteEngine on
RewriteRule zenegra(.*)\.htm$ /pills/meds.php?srch=$1
and this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^meds/([A-Za-z0-9-]+)\.htm$ http://domain.com/pills/meds.php?srch=$1 [L]
just to see if there's any response to it. But none..
:(
# Options +FollowSymLinks
RewriteEngine on
RewriteRule ^fakepage\.html$ http://yoursite.com/ [R,L]
Then type yoursite.com/fakepage.html in your browser. Try as is... if you do not get a response try uncommenting the Options line.
Let us know what you get.
The generator will probably not help you get this one right -- here is an example: /zenegra_sildenafil_citrate\.html
** You will need the number that corresponds to the srch=NUMBER in the static URL somewhere, or you will need a separate rule for every page... (You may anyway, but that will depend on the structure of both friendly and un-friendly URLs.
/NUM/zenegra_sildenafil_citrate\.html
RewriteCond %{THE_REQUEST} \?scrh=([0-9]+)\ /HTTP
RewriteRule ^meds\.php$ http://yoursite.com/%1/zenegra_sildenafil_citrate\.html [R=301,L]
RewriteRule ^([0-9]+)/zenegra_sildenafil_citrate\.html$ /meds\.php?srch=$1 [L]
Justin
Does this have anything to do with putting .htaccess in the "pills" folder?
It depends on the path to the file you are tyring to rewrite.
In the .htaccess the left side of the rule should be the full, server relative, path to the file -leading / and the right side of the rule should be the full, server relative, path to the 2nd location +leading / (For a redirect (seen in the browser) the right side path should be a canonical URL) EG
RewriteRule ^pathto/the/file\.html$ /pathto/theother/file.php [L]
So, the correction of my rules would be:
RewriteCond %{THE_REQUEST} \?scrh=([0-9]+)\ /HTTP
RewriteRule ^pills/meds\.php$ http://yoursite.com/%1/zenegra_sildenafil_citrate\.html [R=301,L]
RewriteRule ^pills/([0-9]+)/([^.]+)\.html$ /meds\.php?srch=$1 [L]
**Changed above to a regular expression -- will capture anyting that is not a .(dot)**
Justin
Added: Remember you will need to corresponding # in the static url if that is how you are going to reference the correct page in you php script.