I am trying to create a rewrite in my .htaccess file for my wordpress site. I need
www.a3performance.com/fastestsuit
to point to
http://www.a3performance.com/legend-fastest-racing-suit/
I am trying this, but it doesn't seem to work?
RewriteRule ^fastestsuit/?$ legend-fastest-racing-suit [NC,L]
Seems that you need to use here Redirect from one folder to new folder.
Something like this:
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
Actually #labris idea worked. For some reason it took a bit for my server to register the .htaccess change.
RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
Related
I'm trying to modify the subdomain name in the URL to make it look nicer. My current URL look something like:
www.mystore.com/productInfo.php?cPath=11_11&productID=222
So, I want to make it nicer by Rewrite in .htaccess in main with this code:
RewriteEngine On
RewriteRule ^productInfo/([0-9_-]+)/([0-9_-]+) productInfo.php?cPath=$1&productID=$2 [NC,L]
When I run and test it on the URL by typing www.mystore.com/productInfo/11_11/222 in the URL it works well. However, when this page is redirected by a different page or is 'refreshed' with a self redirecting a href= link(in which the link is written in php by the previous programmer), the above old link is still visible in the URL instead of the new one.
I am still a beginner while I suspect that I might need to change something in the cPanel/Apache(I think) for this but currently, I am still do not have access to the cPanel control. Is there anything that I might have missed to write in the .htaccess file or I really do need the cPanel control or any other reasons?
Any help is appreciated. Sorry that I could not find similar questions on this.
You can use the following :
RewriteEngine On
RewriteBase /
#redirect /productInfo.php?cPath=foo&productID=bar to /productInfo/foo/bar
RewriteCond %{THE_REQUEST} /productInfo\.php\?cPath=([0-9_-]+)&productID=([0-9_-]) [NC]
RewriteRule ^ productInfo/%1/%2? [L,R=301]
#rewrite new URL to the old one
RewriteRule ^productInfo/([0-9_-]+)/([0-9_-]+) productInfo.php?cPath=$1&productID=$2 [NC,L]
I was wondering how it is possible to remove part of a url with htaccess for example I have a url like this:
http://localhost/item.php?pa=gd34392
now I need to use htaccess to redirect this page or anything like this to a page with this url:
http://localhost/gd34392
I have tried things like this but nothing seems to work and I do not really know my way around htaccess
RewriteEngine on
RewriteRule item.php?pa=$1 /$1 [R=301,L]
You can achieve that using the following rules in your .htaccess:
RewriteEngine On
RewriteRule ^([^/]*)$ /item.php?pa=$1 [L]
Just make sure you clear your cache before testing this.
I want this: RewriteRule ^paper$ /express/index.php?c=p [L] but it does not work. Instead, it's trying to send me to /index.php?c=p, ignoring the subdirectory express altogether. However, RewriteRule ^express/paper$ /express/index.php?c=p [L] works. This is my .htaccess code:
RewriteEngine on
RewriteBase /
RewriteRule ^paper$ /express/index.php?c=p [L]
RewriteRule ^express/paper$ /express/index.php?c=p [L]
The url I WANT is just http://site.com/paper but I have to do http://site.com/express/paper to get the rewrite rule to work.
And yes, I only use one of those rewrite rules at a time.
UPDATE
Well, I'm not really getting any responses, so I'm going to go ahead and close this browser tab. I'll check back now and then but don't be offended if it takes a little while. Thanks for any help offered.
I want to make the old urls point to the new pages. I'm having trouble because the old URL looks like this: http://nilandsplace.com/store/camping_eng/coghlans-campfire-cooking-forks-toaster-forks-package-of-4.html.
I want to do a URL re-right in .ht access from mywebsite.com/camping_eng/some.html to mywebsite.com/camping/some.html, were the "some.html" part is identical.
Only camping_eng changes to camping.
You might want to try this:
RewriteEngine on
RewriteRule ^camping_eng/([a-zA-Z0-9-=_.]+)/?$ http://mywebsite.com/camping/$1 [L,R=301]
This example works according to your question:
from mywebsite.com/camping_eng/some.html
to mywebsite.com/camping/some.html were the "some.html" part is identical.
RewriteEngine on
RewriteBase /store
RewriteRule ^camping_eng/(.*)$ camping/$1 [QSA,L,R=301]
I need a redirect from http://www.mysite.com/passport/365.html to http://www.mysite.com/passport/365.html?task=view
I try to do it like this
RewriteCond %{HTTP_HOST} ^/passport/365.html$
RewriteRule ^/?$ /passport/365.html?task=view [QSA]
and it doesn't work.
Please help.
try that :
RewriteEngine on
RewriteRule ^passport/365\.html$ http://www.mysite.com/passport/365.html?task=view [R]
I think in you example ur missing the **
so it should be something like :
RewriteRule ^/passport/365\.html$ /passport/365\.html?task=view [QSA]
I would recommend you use this plugin.
You can simply add the redirect rule to the plugin without modifying .htaccess
There is a component already build in Joomla called "redirect" where U can set-up your redirects, so you don't have to use .htaccess at all.
Here is a good tutorial: http://www.joomtraining.com.au/tutorials/joomla-1.6/creating-a-page-redirect
The problem with the .htaccess is that every redirect must be set in appropriate place in the file.