Let’s say I have this URL:
http://example.com/search.php?key=abc&advance=xyz&page=1
And I want this URL:
http://example.com/search?key=abc&advance=xyz&page=1
OR
http://example.com/search.html?key=abc&advance=xyz&page=1
Please help me
You can use rewrite engine.
RewriteEngine on
RewriteRule ^(.*)\.php$ $1.html [nc]
Related
I have lot or articles with this URL format:
mydomain/art/details.php?articleid=24463&parentid=1&catid=166
the above is an example.
And i want that redirect these kind of URL to :
mydomain/art/24463.html
Please let me know that how can i do it with .htaccess?
Thanks in advance
Instead of mydomain/art/24463.html you should choose something like mydomain/art-166/1-24463.html.
This way, you'll include also parentid and catid which are dynamic parameters (and so, needed for rewriting).
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/art/details\.php\?articleid=(\d+)&parentid=(\d+)&catid=(\d+)\s [NC]
RewriteRule ^ /art-%3/%2-%1.html? [R=301,L]
RewriteRule ^art-(\d+)/(\d+)-(\d+)\.html$ /art/details.php?articleid=$3&parentid=$2&catid=$1 [L]
Try this in htaccess tester
RewriteEngine on
RewriteRule ^art/(\d+).html$ art/details.php?articleid=$1&parentid=1&catid=166 [nc]
I want to implement a redirect via .htaccess from the old URL:
http://derpiet.de/photos/ireland
to the URL:
http://derpiet.de/photos/alben/2013/07/ireland
The system in the background is koken (http://koken.me).
Is it possible?
So, this will work:
RewriteCond %{REQUEST_URI} ^/photos/ireland/$
RewriteRule .* alben/2013/05/ireland [L,R=301]
Please i need help to create a correct instruction in .htaccess to redirect old urls done in this way:
/it/cartelle/465-piquadro-signo-cartella-ca1744si.html
to
/it/valigeria/cartelle/465-piquadro-signo-cartella-ca1744si-ca1744si.html
in other words we have shifted all category cartelle under category valigeria.
Our .htaccess at the moment is:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.it$
RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
Anyone can help me?
Thanks
You can try this if you want to redirect to a new URL:
RedirectMatch /it/cartelle/(.*) /it/valigeria/cartelle/$1
If you want to keep the old url and just do an internal redirect:
RewriteRule ^/it/cartelle/(.*)$ /it/valigeria/cartelle/$1 [NC,L]
I have url pattern like this.
site.com/page-name?variable-name=variable value
I want this to be site.com/variable - value
I' am not good in rewrite api. Please guide me through .htaccess.
Try this
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)=(.*)
RewriteRule ^(.*) /%1-%2? [R,L]
How to rewrite the url in htaccess
www.mywebsite.com/category.php?name="richard" change to www.mywebsite.com/richard/
You can use below code to achieve your requirement.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} name=(.*)
RewriteRule category\.php$ /%1/
Hope this helps you... :)
Are you used any PHP frameworks(like the codenigter... etc)?
You can try this:
RewriteRule ^(.*)$ /category.php/name=$1 [L]