I already use URL Rewriting to rewrite /foobar to index.php?username=foobar using:
RewriteRule ^([^/.]+)$ /index.php?username=$1 [QSA,L]
What should I add to also rewrite /foobar/rss to rss.php?username=foobar?
This is how it's done:
RewriteRule ^([^/]+)/rss$ /rss.php?username=$1 [QSA,L]
Related
I need a rule that rewrites
http://example.com/page.html?page=2
to
http://example.com/page.html/page/2
I already tried this rule:
RewriteRule ^(.*)page=(.*)$ http://example.com/$1/page/$2/
but this does not work! :( Where I'm wrong?
You can try this one:
RewriteCond %{QUERY_STRING} page=(\d+) [NC]
RewriteRule (.*) /$1/page/%1/? [R=301,L]
It should works.
I am trying to rewrite some URLs using my .htaccess file and the following syntax:
RewriteEngine On
RewriteRule ^movie/([0-9]+)/$ movie.php?id=$1
Basically, the URL http://screeningapp.co.uk/movie.php?id=771316320 should be rewritten to http://screeningapp.co.uk/movie/771316320, but that's not happening and I'm not sure why.
Thanks!
RewriteEngine On
RewriteRule ^movie/([0-9]+)/?$ /movie.php?id=$1 [L,nc]
#if you wanna redirect movie.php?id=1 to movie/1/
RewriteCond %{QUERY_STRING} ^id=([0-9]+)($|&)
RewriteRule ^movie.php$ /movie/%1? [R=301,L,NC]
What I'm looking to do is rewrite the url so that one of the directories are hidden. For example;
http://www.example.com/home/example.html
to
http://www.example.com/example.html
As I'm new to .htaccess and mod_rewrite, is this something that can be done?
This should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/home/.*$
RewriteRule ^(.*)$ /home/$1 [L]
Something like this should work.
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^example.html$ /home/example.html [NC,L]
I have the following rewrite rule in place:
RewriteRule ^register/?$ /fitch/index.php?cmd=register [NC,L,QSA]
Requests to mysite.com/register are rewritten to
mysite.com/fitch/index.php?cmd=register
I want to allow an optional parameter to be passed as well, such that requests to
mysite.com/register/sender=models directs me to
mysite.com/fitch/index.php?cmd=register&sender=models
Perhaps:
RewriteRule ^register/(.*) /fitch/index.php?cmd=register&$1
For any number of paths -> query string params:
RewriteCond %{REQUEST_URI} ^/register/
RewriteRule ^(.*)/(.*)$ /$1&$2 [L]
RewriteCond %{REQUEST_URI} ^/register&
RewriteRule ^(.*)$ /fitch/index.php?cmd=$1 [L,QSA]
This will rewrite URL's like:
http://mysite.com/register/a=b/1=2/c=d
to:
http://mysite.com/fitch/index.php?cmd=register&a=b&1=2&c=d
Hi can anybody help me with this rewrite rule.
Basically i have a url http://mydomain.com/http://somewhere.com/photo.gif which i want it to be forwarded to this url: http://mydomain.com/upload.php?url=http://somewhere.com/photo.gif
I have tried the following but it does not work.
RewriteRule ^(.*)$ upload.php?code=$1 [L]
You haven't added a / for upload.php?...
RewriteRule ^(.*)$ /upload.php?code=$1 [L] will work if you can avoid the http:// in http://somewhere.comwhile passing tohttp://mydomain.com/http://somewhere.com/