I have a page locally that is /shop but I want it to redirect to /shop/designs
I tried to do it with .htaccess but nothing seems to be working.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/shop/.*$ /shop/designs/ [R=301,L]
# 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]
</IfModule>
# END WordPress
Any ideas where I am going wrong?
You were almost there, but in htaccess, you cannot use / at the beginning of the path regex.
Change your rule like so:
RewriteEngine On
RewriteRule ^shop$ shop/designs [R=301,L]
Related
I am trying to redirect http://example.com/for-sale/?property=1234 to http://example.com/for-sale/property-name/ in .htaccess, using RewriteCond and RewriteRule. This is what I have so far:
RewriteCond %{QUERY_STRING} ^(property=1234)
RewriteRule ^$ /for-sale/property-name/? [R=301,L]
This does not work. I can redirect ?property=1234 to for-sale/property-name/ but how do I get it to work with /for-sale/ in the un-redirected URL? I've tried various combinations of for-sale in the RewriteRule but without success.
Thanks.
All my links are now broken so I would really appreciate some advice. Thanks.
This is a wordpress site, so the first mistake was to do the rewrites after wordpress does its rewrites. Second mistake was in the RewriteRule. Here is the working code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} property=1234$
RewriteRule ^for-sale/?$ /for-sale/property-name/? [R=301,L]
... my other rewrites
</IfModule>
# 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]
</IfModule>
# END WordPress
This works. Hope it helps someone else out.
I'm struggling with some redirects on the redesign of a website.
The old one got several urls like this:
http://www.example.com/sitegroup/pages/GA/GA_Be.shtml
And I want to redirect this to:
http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten
I tried it with the following rewriterule:
RewriteRule ^/?pagesGA/GA_Be.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten$1 [R=301,L,NE]
But I just can't get it working.. I'm really new to .htaccess rewriterules.
Also some of the old pages got links like this:
http://www.example.com/sitegroup/pages/GA/GA_Be.shtml?navid=15
But the ?navid=15 isn't doing something(just highlighting the menulink) so I thought just redirecting the GA_BE.shtml should be enough. Am I correct?
Here is the complete .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sitegroup/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sitegroup/index.php [L]
</IfModule>
# END WordPress
RewriteRule ^/?pagesGA/GA_Be.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten$1 [R=301,L,NE]
Thanks in advance!
You should put your RewriteRule before Wordpress Dispatcher:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sitegroup/
RewriteRule ^pages/GA/GA_Be\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenforum-ideengarten [R=301,L,NE]
RewriteRule ^pages/GA/GA_Bg\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#gartenplanung-landschaftsplanung [R=301,L,NE]
RewriteRule ^pages/GA/GA_En\.shtml$ http://www.example.com/sitegroup/garten-und-landschaftsbau/#erdsondenbohrung-erdwaerme [R=301,L,NE]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sitegroup/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sitegroup/index.php [L]
</IfModule>
# END WordPress
Otherwise the request will first be handled by the Dispatcher and never reach your rule.
How can I use htaccess to redirect a few static pages and keep the same url?
Example :
Redirect www.mydomain.com/url-that-remains.php to www.mydomain.com/page-number-23
My current htaccess file looks like that:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This code should work:
RewriteEngine On
RewriteRule ^url-that-remains\.php$ /page-number-23 [L,NC]
Try like this
RewriteEngine On
RewriteRule /somestaticpageonyourwebsite.html /yournewpage.html [R=302]
EDIT:
I don't know why the above doesn't work. This should work.
RedirectPermanent /somestaticpageonyourwebsite.html /yournewpage.html
i want to change urls of my website, but there many pages, so i cant change them manually.
so i need to change it from htaccess file.
i want to change the below url
http://demos.beusoft.com/ccjk/resource/arabic-translation-services/
with the
http://demos.beusoft.com/ccjk/arabic-translation-services/
i am using wordpress.
this is whole code ....
# BEGIN WordPress
RewriteEngine On
RewriteRule ^ccjk/resource/([^/]+)/$ demos.beusoft.com/ccjk/$1 [L,R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ccjk/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ccjk/index.php [L]
</IfModule>
# END WordPress
please help, how to rewrite the url from the htaccess file.
Try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ccjk/
RewriteRule ^resource/([^/]+)/$ http://demos.beusoft.com/ccjk/$1/ [L,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ccjk/index.php [L]
</IfModule>
# END WordPress
I tried a lot of code without results.
I'm using wordpress and the url of search results is:
http://mysite.com/search/the%20search%20query%20
I need to change it in
http://mysite.com/search/the-search-query/
Is there a way with htaccess?
This is actually my 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]
</IfModule>
Options +FollowSymlinks -MultiViews
RewriteRule ^(.+)(\s|%20)(.+)$ /$1-$3 [R=301,QSA,L,NE]
# END WordPress
The last rewrite rule is what i trie without success
Your rule looks fine, however you have it after your routing rules. That means no matter what, that rule will never be reached because everything, including any request with a space in it, gets routed to index.php. You need to put any redirect rules before your routing rules:
Options +FollowSymlinks -MultiViews
RewriteRule ^(.+)(\s|%20)(.+)$ /$1-$3 [R=301,QSA,L,NE]
# 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]
</IfModule>
# END WordPress