<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^browse/videos/(.*)/(.*)/(.*)/(.*) /videos.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^videos/(.*)/(.*) /playvideo.php?videoid=$1&title=$2
</IfModule>
url www.example.com/browse/videos/z/0/1/LastAdded goes to videos.php
but url www.exaple.com/videos/10/play.html also goes to videos.php not to playvideo.php
Why?
This could be caused by MultiViews. Try to disable it with:
Options -MultiViews
Furthermore, you should use more specific pattern than .*, for example [^/]+:
RewriteRule ^browse/videos/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /videos.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^videos/([^/]+)/([^/]+)$ /playvideo.php?videoid=$1&title=$2
Not sure why that is hapenning to you but anyway you should be using something like this.
RewriteRule ^browse/videos/(.+)/(.+)/(.+)/(.+) /videos.php?sortby=$1&filter=$2&page=$3&title=$4 [L]
RewriteRule ^videos/(.+)/(.+) /playvideo.php?videoid=$1&title=$2 [L]
It works for me. To track down why it doesn't work for you, you should enable mod_rewrite logging:
RewriteLogLevel 9
RewriteLog logs/rewrite.log
Then you should try to understand what's written there. And if you don't understand it, post it here and we will try to explain it.
Related
I've been struggling with this very rare problem.
I had the following code in my .htaccess file:
Order deny,allow
DirectoryIndex index.php
RewriteEngine on
Rewriterule ^producto/(.+)/(.+) producto.php?id=$1&title=$2
Rewriterule ^pedidos/ pedidos.php
Rewriterule ^peliculas/(.+)/(.+) listado.php?tipo=1&gen=$1&pag=$2
Rewriterule ^musicales/(.+)/(.+) listado.php?tipo=2&gen=$1&pag=$2
Rewriterule ^blueray/(.+)/(.+) listado.php?tipo=4&gen=$1&pag=$2
Rewriterule ^condicionadas/(.+)/(.+) listado.php?tipo=5&gen=$1&pag=$2
Rewriterule ^series/(.+)/(.+) listado.php?tipo=3&gen=$1&pag=$2
And everything worked fine. When I wanted to change the fifth line:
Rewriterule ^pedidos/ pedidos.php
to this:
Rewriterule ^pedidos/(.+) pedidos.php?estado=$1
It did not work. No matter how much I change that line, it won't work.
BUT if I change any other line, the change works.
It's like there's a cached file but I restarted WAMP, I cleaned my computer and browsers with CCleaner, and nothing works.
Can you help me with this?
Try to add that before RewriteEngine on:
Options -MultiViews
Need help, It is basic Mod-Rewrite. But i am confused
My current URL:
http://example.com/category.php?fn=accounting-tax
Want look like this:
http://example.com/category/accounting-tax
Only Apache Mod-Rewrite, No PHP please
Update:
Is it possible without PHP?
Thank you
Add this to your .htaccess in your web root /
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)fn=(.*)(&|$)
RewriteRule ^category\.php$ category/%2 [NC,L]
Assuming, you meant
/category.php?fn=accounting-tax should take you to /category/accounting-tax
without showing up on the address bar. If you want an external redirect use [R=301,NC,L] instead.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^category/([a-z0-9\-]+)/item/?$ /category.php?id=$1
</IfModule>
Can somebody tell me how to get mod_rewrite to rename this:
our-work-section.php?id=3&title=something
to
our-work-section/something/3
Right now my .htaccess is in directory C:\workspace\www\brown, My vhost is setup for http://workspace/, So I did a RewriteBase below. I currently Have:
RewriteEngine On
RewriteBase /www/brown/
RewriteRule ^/our-work-section/?$ our-work-section.php?id=$1 [NC,L]
My error log isn't saying anything, and the page doesn't do anything. I've tried toggling slashes / here and there.
Try this one
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(our-work-section)/?$ /our-work-section.php?id=$1 [L]
EDIT
This one will work. I tested it
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(our-work-section)/([^/\.]+)/?$ /our-work-section.php?id=$1 [L]
This is what I have, but it is not working.
RewriteRule ^location/([a-zA-Z0-9_-]+)/reviews$ location.php?purl=$1&page=reviews [L]
RewriteRule ^location/([a-zA-Z0-9_-]+)/reviews/$ location.php?purl=$1&page=reviews [L]
Can anyone show me what I am doing wrong?
http://www.example.com/this-location-1234/reviews/ to http://www.example.com/location.php?purl=this-location-1234&page=review
You should combine those two (nearly identical) rules, and make sure you have the RewriteEngine on and your rule is being run (either your .htaccess is getting picked up, or you have this in an active vhost definition).
RewriteEngine on
RewriteRule ^location/([a-zA-Z0-9_-]+)/reviews/?$ location.php?purl=$1&page=reviews [L]
I fixed it. I accidentally was missing some verbiage in the link I was getting an error on.
RewriteRule ^location/([a-zA-Z0-9_-]+)/reviews/?$ location.php?purl=$1&page=reviews [L]
This works great!
I think this should work for the example URLs you given:
RewriteRule ^([a-zA-Z0-9_-]+)/reviews/?$ location.php?purl=$1&page=reviews [L]
(replace the two rewrite rules with this one)
If you don't already have one, add RewriteEngine on before this RewriteRule.
If you actually wanted to rewrite /location/this-location-1234/reviews/ instead of /this-location-1234/reviews/, then use this:
RewriteRule ^location/([a-zA-Z0-9_-]+)/reviews/?$ location.php?purl=$1&page=reviews [L]
I assume you have another property in your conf file called RewriteEngine on ?
Also, you can turn on the logging with RewriteLogLevel.
Is there any way i can use RewriteRule to show these links:
/articles_history.php
/articles_geography.php
as
/articles/history.html
/articles/geography.html
I created a .htacesss file on my root directory and would like to know if the above is possible by placing some kind of code in the .htaccess file.
RewriteEngine On
RewriteRule /articles/(.+)\.html /articles_$1.php [L,QSA]
Yes it is.
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
In addition to RewriteRule, you also need to usually turn the rewrite engine on by the RewriteEngine directive.
Try this in your .htaccess:
RewriteEngine on
RewriteRule ^article/([^/]+)\.html$ articles_$1.php [L]
And for an arbitrary input:
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)\.html$ $1_$2.php [L]