I need some help writing a .htaccess file for the following scenario:
The user enters this address: http://subdomain.domain.com/name and should be redirected to http://subdomain.domain.com/#/name
Thank you very much.
RedirectMatch ^/name$ /#/name
or if you mean that "name" can be anything:
RedirectMatch ^/(.+)$ /#/$1
Related
I am trying to redirect the following:
Redirect 301 /fruit/ https://www.website.com/vegetables/
^ The above works great IF the user clicks a link. However, should the user type-in the URL and omit the trailing slash after 'fruit' then it throws a 404.
So, my question is, how do I make all reference to /fruit/ or /fruit work correctly under 301 protocol?
Thanks for all replies
Google was my friend: the answer is >
RedirectMatch 301 /fruit/?$ https://www.website.com/vegetables/
I need to redirect whole directory to another
like :
http://test.com/en/file1.php
http://test.com/en/file2.php
http://test.com/en/file3.php
http://test.com/en/file4.php
http://test.com/en/directory
to
http://test.com/fa/file1.php
http://test.com/fa/file2.php
http://test.com/fa/file3.php
http://test.com/fa/file4.php
http://test.com/fa/directory
how ?
You can place this line as first line in your root .htaccess:
RedirectMatch 301 ^/en/(.*)$ /fr/$1
a simple request I'm sure but can't for the life of me find an answer.
I would like the following...
http://example.co.uk/menu/item1, http://example.co.uk/menu/item2, http://example.co.uk/menu/item3 etc.
To redirect to http://example.co.uk/menu/.
Currently I am using the rule below but am getting a redirect loop on /menu/.
RedirectMatch 302 ^/menu/.*$ http://example.co.uk/menu/
How do I create a rule that redirects only what I require and leaves /menu/ accessible?
Thanks.
Tweak your regex a little by matching 1 or more characters after /menu/:
RewriteRule ^menu/(.+)$ /menu/ [L,R=301]
I do not understand htaccess fully so I need help solving this. I need to redirect users from the directory www.example.com/es and www.example.com/en to the subdirectory www.example.com/old/es and www.example.com/old/en.
Add this in the htaccess file in your document root:
RedirectMatch 301 ^/(en|es)(/.*)?$ /old/$1$2
If you only want to redirect /en and /es, and not /en/foo or /es/something/else then remove the $2 bit from the end.
Here is my problem...
I have a to redirect a link like this:
site.com/virtualfolder/some-seo-friendly-keywork
to
site.com/folder/page.php?id=some-seo-friendly-keyword
In site.com there is no real folder "virtualfolder", it is virtual.
I have to take "some-seo-friendly-keyword" and use it as a query string
I think i have to firts match the folder "virtualfolder" and then capture the "some-seo-friendly-keyword", but how?
The some-seo-friendly-keyword is a string of characters and digits plus hypens so something like this below is realistic?
RewriteRule ^virtualfolder/([a-zA-Z0-9-])? folder/page.php?id=$1 [L]
I'm still strudying and trying mod_rewrite and it is like voodoo to me! :-/
Thank you very much for your help or your suggestions
Try with this code in htaccess:
Using the original url to show:
Rewriterule ^virtualfolder/([a-zA-Z0-9_-]+)$ folder/page.php?id=$1
Redirecting to end url using RedirectMatch (use the full URL in the second part):
RedirectMatch 301 ^/virtualfolder/([a-zA-Z0-9_-]+)$ http://www.site.com/folder/page.php?id=$1
Redirecting to end url using mod_rewrite (use the full URL in the second part):
Rewriterule ^virtualfolder/([a-zA-Z0-9_-]+)$ http://www.site.com/folder/page.php?id=$1 [R=301,L,NE]
More info here