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
Related
On my CodeIgniter site, I would like to add a specific rewrite rule, so that this url
http://www.exemple.com/cache.manifest
would rewrite to
http://www.exemple.com/controller/manifest
(because Safari 7 seems to only accept .manifest files for ApplicationCache)
So I try to add this line to my htaccess
RewriteRule ^cache.manifest$ controller/manifest
I added it before the other rewrite rules :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^cache.manifest$ controller/manifest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
But it returns a 404. If I change the line to
RewriteRule ^cache.manifest$ test.html
it works. So the first part on my rule is correct.
If I try to access directly to www.example.com/controller/manifest, it works to, so my url is correct.
I tried also
RewriteRule ^cache.manifest$ index.php/controller/manifest [L]
But it doesn't work either…
Any clue ?
Thanks a lot
I tried some tests on my local server and I think the following might work:
RewriteRule ^cache.manifest$ /index.php/controller/manifest [R,L]
I am not entirely sure if you need the leading "/" or "/index.php", so you
may need to experiment.
You need the [R] flag to force a redirect. In this situation, you want Apache
to look for the string cache.manifest in the URL, and then go to the CI page
controller/manifest.
It appears that you need to explicitly set the redirect.
Please let me know if this works. Good luck!
i managed to make htaccess working on mac os x but the subcateg rule returns a file not found (404) as i guess does search from the articles folder(?)
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /ks
RewriteRule ^articles/(.*).html$ articles.cfm?subcateg=$1 [NC,L]
RewriteRule ^articles.html$ articles.cfm [NC,L]
The second one seems to be working fine...
Looking at your code, your RewriteBase is /ks/ folder, which means you access it with domain.com/ks/articles/xxxxx.html or domain.com/ks/articles.html and your htaccess is in /ks/ folder.
If that's right, you should disable MultiViews option to avoid your problem.
This code should work on osx, too
Options +SymLinksIfOwnerMatch -MultiViews
RewriteEngine On
RewriteBase /ks/
RewriteRule ^articles/(.+?)\.html$ articles.cfm?subcateg=$1 [NC,L]
RewriteRule ^articles\.html$ articles.cfm [NC,L]
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]
<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.
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]