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]
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
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]
I want to redirect all links that have .html extension to a process.php file with directory + page name as get parameter. I have tried these link1 link2 solution but it does not work.
for e.g
http://localhost/Site/directory1/test1.html
http://localhost/Site/directory2/test2.html
to redirected to process.php as
http://localhost/Site/process.php?directory1/test1.html
http://localhost/Site/process.php?directory2/test2.html
I have tried like this.
RewriteEngine on
RewriteRule ^/(.*).html /process.php?page=$1
and this
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*/)?([^/]*)\.php$ /process.php?page=$2 [R=301,L]
but it does not work.
Please see and suggest any possible way to do this.
Try this:
RewriteEngine on
RewriteRule ^([^/]*)/(.*\.html) /$1/process.php?page=$2 [R=301,L]
Your second example is very close to what I believe your looking for. Your just off by one directory and your looking for .php when you should be looking for .html. Give this a try.
RewriteEngine on
RewriteBase /
RewriteRule ^/(.*)/(.*)/(.*)\.html$ /Site/process.php?$2/$3 [R=301, L]
This should do(assuming that the .htaccess file lives in the Site directory):
RewriteEngine On
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*?/)?(.*)$ /$1/process.php?page=$2 [R=301,L]
I've been trying for the last few hours to do something that seems simple..
http://www.mydomain.com/u/username
redirect that to
http://www.mydomain.com/goto.php?u=username
In apache or IIS?
in apache you could use an .htaccess with (in the u folder)
RewriteEngine on
RewriteRule ^([^/]*)/([^/]*)/$ goto.php?u=$2 [L]
If on IIS and you have the latest version, you can import .htaccess into it quite easily with a tool that comes with it
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^u/(.*)$ goto.php?u=$1 [L]
</IfModule>
Edit: To redirect using a HTTP 302/301 response use this:
RewriteRule ^u/(.*)$ goto.php?u=$1 [R=301,L]
or
RewriteRule ^u/(.*)$ goto.php?u=$1 [R,L]
I have used rewrite url module but I am not able to redirect to the target page and
I am getting error as:
The requested URL /old.html was not found on this server.
Here is my code:
<IfModule mod_rewrite>
RewriteEngine On
RewriteRule ^old.html$ new.html [R]
</IfModule>
Is AllowOverride set to All in your httpd.conf? Like this:
AllowOverride All
Also, your .htaccess should inlcude the L modifier for the last rule, and if you really want to redirect permanently, R=301:
RewriteEngine On
RewriteRule ^old.html$ /new.html [R=301,L]
You need to escape the . in .html with a \
So its:
RewriteEngine on
RewriteRule ^old\.html$ new.html [R]
Try also setting the RewriteBase to / like so
RewriteBase /
I've also tried this code for
RewriteEngine On
RewriteBase /
RewriteRule ^old.html$ /new.html [R=301,L]
error as The requested URL /old.html was not found on this server.
How to check the load module in apache server?