I need to create a rewrite rule for the following URL and I need to pass "id" and widget with the GET superglobal
http://www.domain.com/index.php?id=1866&widget=Dangerfield
Is it possible to only use the widget parameter & value in the re-written URL and still be just as functional, and if so, how?
Simple you'd add this to your .htaccess
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id=$1&widget=$2 [L]
The original URL:
http://www.domain.com/index.php?id=1866&widget=Dangerfield
The rewritten URL:
http://www.domain.com/1866/Dangerfield.html
This is search engine friendly, your pages would be easily SEOed in search engines with a .html extension. It's better than having parameter at the end of the url which isn't seo friendly.
Steering assistance subdomain
The original URL:
http://domain.com/index.php?cat=cats&id=12&url=stackoverflow
The rewritten URL:
http://cats.domain.com/12/stackoverflow.html
Code to rewrite rule for above in .htaccess
Related
I am trying to mask the following url with any page number using htaccess.
https://sampledomain.com/?page=2
to
https://sampledomain.com/page/2
So if we call https://sampledomain.com/page/2 url in the website, internally path should always be calling https://sampledomain.com/?page=2 url
Please suggest me the correct htaccess rule.
In htaccess in your document root, use the following rule :
RewriteEngine on
RewriteRule ^page/([0-9]+)/?$ /?page=$1 [QSA,L]
hello I have an indexed page, whose url: website.ext/recensione/43-Dungeons--Dragons-Neverwinter-PS4
Unfortunately I had to change the structure in the url: website.ext/recensione/43-dungeons--dragons-neverwinter-neverwinter---un-dd-allennesima-potenza
There is no way to make the redirect via .htaccess?
Add this rule to your htaccess file and it will work.
RewriteRule ^recensione/43-Dungeons--Dragons-Neverwinter-PS4$ /recensione/recensione/43-dungeons--dragons-neverwinter-neverwinter---un-dd-allennesima-potenza? [L,R=301]
I am cleaning up some old stuff and I need to do some 301 redirects.
For example:
I have following absolute url: http://mysite.dk/product.asp?product=371&sub=0&page=1
That i need to redirect to:
http://mysite.dk/category/test
I have tried with htaccess:
RedirectMatch 301 /product.asp?product=371&sub=0&page=1 /category/test
But above code will not work, It is showing the 404 page and ignoring the redirect I just made. Note please that product.asp does not exists as a file!
However if I use:
RedirectMatch 301 /product.asp /category/test/
It works sort off, but now I can't do redirects, based on the query string for that specific file.
Any suggestions? Btw I am using Prestashop=)
Best, Simon
You cannot match query string using RedirectMatch directive. Use mod_rewrite rule instead:
RewriteEngine On
RewriteCond %{QUERY_STRING} product=371&sub=0&page=1
RewriteRule ^product\.asp$ /category/test/? [L,NC,R=301]
? in the target is to strip off existing query string.
mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.
from here
Just add the rules from #anubhava answer into Prestashop .htaccess and it will works. Better to do it before # ~~start~~ line, you will see notice in the file.
I'd like to use ReWrite to use SEO friendly urls that point to a dynamic url.
For example:
I want the SEO Friendly URL: www.example.com/1/Bird/
to bring up content from the dynamic URL: www.example.com/painting-details.cfm?ID=1&Type=Bird
This is the ReWrite that I've tried in the .htaccess file with no luck:
RewriteEngine on
RewriteRule /(.*)/(.*)/$ painting-details.cfm?ID=$1&Type=$2
Any help is greatly appreciated.
Just needed to get rid of the first slash. .htaccess should read:
RewriteEngine on
RewriteRule (.*)/(.*)/$ painting-details.cfm?ID=$1&Type=$2
I am using PHP and I need to use a name say "Pranav dave" in url which should redirect me to "myprofile.php" what should i do?.. also the url should display me "Pranav dave".. and what should be the htaccess rule to redirect any html file to php file?
You could make it like this:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ myprofile.php?profile=$1 [NC]
After that, you can use your urls like this http://example.com/Pranav dave. The only problem is, that the browser will rewrite the url, and after that, its looking like followink one http://example.com/Pranav%20dave