I am trying to get /game/game-name/ to redirect to /game.php?g=game-name
The code I am using in my .htaccess is:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^game/([a-zA-Z0-9]+)/$ game.php?g=$1
But when I go to /game/game-name/ I get a 404 Error. Any help would be appreciated.
Thanks!
That's because your rule transform this url /game/game-name/ into this /game/game-name/game.php?g=game-name
What you need to do is either this :
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^game/([a-zA-Z0-9]+)/$ /game.php?g=$1
Or this :
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^game/([a-zA-Z0-9]+)/$ game.php?g=$1
Related
I have been trying to rewrite a url like this:
/gallery/test.php?id=1
to this:
/gallery/test/1
However it isn't working. I have url rewriting enabled and have used phpinfo() to check.
this is my code:
Options +FollowSymLinks -Multiviews
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine on
RewriteRule ^test/([0-9]+)/?$ test.php?id=$1 [NC,L]
</IfModule>
You probably need a rewrite base. Try adding the following on the line after the RewriteEngine on line.
RewriteBase /gallery/
this is a rewrite rule that should work
RewriteEngine On
RewriteRule ^gallery/test/([^/]*)$ /gallery/test.php?id=$1 [L]
Thanks
Hi this is the RewriteRule that i am trying to apply
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^coloragon/([^/]*)\.html$ /coloragon/pair_pixel_filter.php?type=$1 [L]
for the following URL
http://localhost/coloragon/pair_pixel_filter.php?type=0
but it do not seem to work at all. Any suggestions will be appreciated.
I'm using the following configuration in .htaccess to try to rewrite URLs of the form http://www.mysite.com/subdir/page.php?param=4 to http://www.mysite.com/subdir/page/param/4:
# Turn on the rewrite engine
Options +FollowSymlinks
RewriteEngine on
# Request routing
RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$1 [nc,qsa]
However, I get an Internal Server Error when I visit the page. Is there something wrong with the configuration?
EDIT: I've updated it to the following, but now it does not seem to be doing any rewriting and gives me a 404 when I try to use a URL like http://www.mysite.com/subdir/param/2:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^name=([0-9]+)$ [NC]
RewriteRule ^project-testing/ws/index.php$ /project-testing/ws/name/%1 [R=301,NC,L]
You need to use %{QUERY_STRING} to read the query string of your URL to redirect based on it.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^param=([0-9]+)$ [NC]
RewriteRule ^subdir/page.php$ subdir/page/param/%1 [R=301,NC,L]
Or if you want that accessing:
http://www.mysite.com/subdir/page/param/4
Shows the content of:
http://www.mysite.com/subdir/page.php?param=4
Then it would be like this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^subdir/page/([^/]+)/([^/]+)$ subdir/page.php?$1=$2 [NC,L]
Thanks in advance !! Actually i am suffring from url rewriting problem in php (apache server). Problem is :
I have to write
URL(Old)= abc.com/search_result.php?id=110 to
URL(New)= abc.com/110
it is working in opposite direction when i click the url abc.com/search_result.php?id=110 it does not change to abc.com/110
but when i click the url abc.com/110 it changes to abc.com/search_result.php?id=110
.htaccess code
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9]+)$ http://www.abc.com/search_result.php?id=$1
website linnk : [ncrfloors.com][1]
Please anybody help me.....
On your old domain: Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search_result\.php\?id=([^\s]+) [NC]
RewriteRule ^ http://abc.com/%1? [R=301,L]
I am trying to redirect the url:
'mysiteurl/Actors/as23sderd/1' to 'mysiteurl/cataImages.php?c=Actors&p=1'
using the following htacess code:
RewriteEngine On
RewriteRule ^([\w]+)/([a-zA-Z0-9]+)/([0-9]+)$ cataImages.php?c=$2&p=$3
But it is not redirecting now.
Please help me.
RewriteEngine On
RewriteRule ^([\w]+)/([a-zA-Z0-9]+)/([0-9]+)$ cataImages.php?c=$1&p=$3
This is what you need:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^[^/]+/([^/]+)/([0-9]+)/?$ cataImages.php?c=$1&p=$2 [L,QSA,NC]