Rewrite rule not working in htaccess - .htaccess

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.

Related

.htaccess rewrite not working with my site

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

.htaccess Rewrite Rule 404 Error

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

mod_rewrite .php being added to end, how change to just before first slash?

I am trying to remove .php from my urls and so I am using this htaccess code:
RewriteEngine on
Options +SymlinksIfOwnerMatch +MultiViews
RewriteBase /
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]
This works fine for urls like this mydomain.com/news
But for urls like this mydomain.com/news/1/news_title it's being rewritten as mydomain.com/news/1/news_title.php which obviously gives a 404 error. Can anyone help me change the RewriteRule to add .php to just after the first forward slash instead of at the end so that the url is rewritten mydomain.com/news.php/1/news_title?
Many thanks for any help and advice
I hope this will work for you:
RewriteEngine on
Options +SymlinksIfOwnerMatch +MultiViews
RewriteBase /
RewriteRule ^([^/]+)(.*) /$1.php$2 [L]

Rewrite rule in htaccess is not working properly

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]

mod rewrite with htaccess

I am trying to write a htaccess file with mod rewrite but no luck.
The original url is
http://www.bpages.com/beta/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=1770&sobi2Id=94872&Itemid=
I want the new url should be
http://www.bpages.com/beta/abc/xyz
catid=1770 refers to abc,
sobi2Id=94872 refers to xyz,
beta is a sub directory
Is it possible.Please suggest the best possible way.
Thanks in advance,
Prithvi
The following should do what you want, though I haven't tested it. Also... the Itemid part is empty. Was that just a mistake, or is it supposed to be empty?
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^beta/([^/]+)/(.+)$ beta/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=$1&sobi2Id=$2&Itemid= [NC]
</IfModule>
If I understood your question correctly then these rules should work:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} catid=([^&]+)&sobi2Id=([^&]+)& [NC]
RewriteRule ^(beta/.*)$ /$1/%1/%2? [L,R,NC]

Resources