ISS ReWrite - SEO friendly URL to Dynamic Page - .htaccess

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

Related

Rewrite example.com/index.php/... to example.com/... using mod_rewrite and .htaccess

I am migrating my site from Wordpress to Jekyll and I would like to keep the URLs working. My idea was to use a .htaccess file for this and to place it in the root of the site. But unfortunately after trying several tutorials and generates it doesn't seem to work.
The old URLs have the following format
http://example.com/index.php/2016/05/07/title-of-the-blog-post/
The new URLs have this format:
http://example.com/2016/05/07/title-of-the-blog-post.html
Among others I've tried this example which looks good to me, but it actually casues all pages on my site to display an error message :)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^index.php.*$ http://example.com/ [R=301,L]
I think that should take all URLs that start with example.com/index.php and make them start with example.com/, but apparently that is not the case.
To redirect
http://example.com/index.php/2016/05/07/title-of-the-blog-post/
to
http://example.com/2016/05/07/title-of-the-blog-post.html
you can use the following rule :
RewriteEngine on
RewriteRule ^index\.php/(.+)$ http://example.com/$1.html [NE,L,R]
or alternatively you can use mod_alias like that:
RedirectMatch 301 ^/index\.php/(.+)$ http://example.com/$1.html

URL Rewrite Rule .htaccess

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

.htaccess redirect remove "?_route_=" form URL

I am using .htaccess redirect in my website. I am using those code
Redirect /addgiftmr/widgetjs.aspx https://www.mysite.com/
But when redirect, it is adding extra word. I am getting url as https://www.mysite.com/?route=addgiftmr/widgetjs.aspx
how can I remove ?route=addgiftmr/widgetjs.aspx form link?
Here is how to do it in .htaccess if mod-rewrite is installed. The advantage of mod-rewrite is that it is easier to expand later if you want to use more complex rules.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^addgiftmr/widgetjs.aspx https://www.mysite.com/ [L,R]

htaccess redirection for joomla page

How to do an htaccess redirection for the following
http://goozga.com/demo/index.php?option=com_content&view=article&id=70
needs to rewrite the above URL to
http://goozga.com/demo/index.php?option=com_content&view=article&id=73
please help me?
Try something like:
RewriteCond %{QUERY_STRING} option=com_content&view=article&id=70$
RewriteRule .* index.php?option=com_content&view=article&id=73 [L]
Note that your question has nothing to do with Joomla but depends on Apache's mod_rewrite instead.
Within Joomla, you can also use the Redirect component. You would just have to add a new redirect rule with the first URL as the source and the second as the destination URL.

htaccess rule for redirection of any particular name to particular page

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

Resources