Rewrite URL using .htaccess (adding query string) - php

http://www.naissancebebe.com/index.php?fc=module&module=prenoms&controller=search&gender=boy
I want to rewrite this using .htaccess to this way
http://www.naissancebebe.com/boy.php
so this query string "index.php?fc=module&module=prenoms&controller=search&gender=boy" add in .htaccess file.
here is my code
#RewriteEngine On
RewriteRule ^boy.php /index.php?fc=module&module=prenoms&controller=search&gender=boy [L]

Try :
Options -Multiviews
RewriteEngine On
RewriteRule ^boy\.php$ /index.php?fc=module&module=prenoms&controller=search&gender=boy [QSA,NC,L]

Related

htaccess rewrite URL php parameters

I am trying to rewrite a specific PHP file GET parameter but cant seem to get things to work.
I want to rewrite http://www.example.com/meeting.php?ref=y0fpjXrrGP so it is http://www.example.com/meeting/y0fpjXrrGP
What am I mising on the below? Note I am using WordPress so adding to the existing htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^meeting/(.*)$ meeting.php?ref=$1
</IfModule>
# END WordPress
Options -Indexes
Adding RewriteRule ^meeting/(.*)$ meeting.php?ref=$1 does not seem to work at all.
Just use this in your .htaccess file:
RewriteEngine On
RewriteRule ^meeting/([^/]*)$ /meeting.php?ref=$1 [L]
It will leave you with the URL: http://www.example.com/meeting/y0fpjXrrGP
Make sure you clear your cache when testing this.
You don't need to add that to .htaccess, if your URL is inside your Wordpress, you need to add them to the rewrite URL
Check this:
How to create custom URL routes?
Hope it helps.

How to remove subdirectories using mod_rewrite in .htaccess

All my site url reads
http://example.com/myfolder/main/other/extra/index.php
I want it to rewritten as
http://example.com/index.php
Try the below rule :
Options +FollowSymlinks
RewriteEngine on
rewriterule ^myfolder/main/other/extra/index.php(.*)$ http://example.com/index.php$1 [r=301,nc]

Htaccess rewrite no extension or slash

I want every file on my server like this
"mywebsite.com/video?id=vgIjgt863_53",
I have php so at the moment it would look like this
"mywebsite.com/video.php?id=(id)"
I need this in htaccess
Put your htaccess in root folder with this code
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.+)$
RewriteRule ^video$ /video.php?id=%1 [L]

rewriting url for query strings

Hi I want To Ask How Can I convert
http://abc.tk/comments.php?post_referrel_id=16
to
http://abc.tk/comments.php?post_referrel_id/16
using .htaccess mod_write
RewriteBase /
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^comments\.php\?post_referrel_id/([^/]*)$ /comments.php?post_referrel_id=$1 [L,QSA]
RewriteEngine on
RewriteRule comments.php?(.*)/(.*)/$ /comments.php?$1=$2 [L]
A URL rewrite wouldn't matter in this instance, as your still using query strings. It would make more since to eliminate the Query string all together with something like:
http://abc.tk/comments.php/post_referrel_id/16
Nevertheless, this can be achieved using .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule comments.php?post_referral_id/(.*)$ /comments.php?post_referral_id=$1 [L]
</IfModule>
Which will still use the same code, but be recognized by a different URL.
Check this out.
RewriteEngine On
RewriteBase /
RewriteRule ^comments\.php\?post_referal_id/([^/]*)$ /comments.php?post_referrel_id=$1 [L,QSA]

apache rewrite static url to dynamic

I'm try to rewrite my url
http://www.domain.com/live/randomword
it should go rewrite to
http://www.domain.com/live/?cat=randomword
here are my tests:
RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1
and all i have in the htaccess file is:
RewriteEngine on
You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:
RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]
If this still doesn't work be sure to check that mod_rewrite is enabled
also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.
hope this help
Have this code in your .htaccess file:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]
in rewrite rule the file name or extension in missing?
write rule like,
RewriteRule ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1

Categories