When I try to redirect an URL, I have a "localhost//" that suits before my new URL
I'm writing in the .htaccess like that :
"RewriteEngine On
Redirect301 / www.site.com"
and the result in the navigator is : "localhost//www.site.com"
Thank you
You want to redirectfrom your "old domain" or from localhost to the other site ?
if yes, then try to use:
Options +FollowSymLinks
RewriteEngine on
RedirectMatch 301 ^(.*)$ http://www.site.com
Related
i want to know the way to configure mod rewrite to achieve the following.
http://example.com/path1/path2/path3/.../pathn
should be redirected to.
http://example.com/static/path1/path2/path3/pathn
Thanks
RewriteEngine on
RewriteRule ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/.*/(.*)$ http://example.com/product/$1/$2/$3/$4
You can use mod-alias (RedirectMatch) directive for this redirection :
RedirectMatch ^/path1/path2/path3/?$ http://example.com/static/path1/path2/path3
If the old uri is dynmic , you could use regex to handle it :
RedirectMatch ^/(path1/.+)$ http://example.com/static/$1
The first redirect will redirect /path1/path2/path3 to /static/path1/path2/path3 and the second Redirect will redirect /path1/foo/bar to /static/foo/bar .
If you want to use mod-rewrite , you can use the following rule :
RewriteEngine on
RewriteRule ^/?(path1/.+)$ http://example.com/static/$1 [L,R]
I want to rewrite URLs from my-custom-url.com/abc/admin/anypage/ to my-custom-url.com/def/admin/anypage/
I have already taken a look to http://httpd.apache.org/docs/2.0/misc/rewriteguide.html, chapter "Moved Document Root"
I opened .htaccess in root directory (which refers to http://www.my-custom-url.com/), looked for <IfModule mod_rewrite.c> and included the following code:
RewriteEngine on
RewriteRule ^/abc/admin/$ /def/admin/ [R]
I tried also:
RewriteRule /abc/admin/ /def/admin/
Both didn't work. What's wrong?
First of all, take shure, that you are allowed to use .htaccess and modRewrite
To take shure:
write some nonsenss in your .htaccess eg asdfasdf as fasdfa
This should exec an Internal Server Error When you get the error, delete the nonsenss .-)
Then try this:
RewriteEngine on
RewriteRule ^test-the-world/$ http://www.google.de [L]
RewriteRule ^abc/admin/$ /def/admin/ [R,L]
Then open the URI's:
http://example.com/test-the-world/ -> when successful you go tho google.de
http://example.com/abc/admin/ ->when successful you go to /def/admin/
I need to change abc.mydomain.com/xyz.php?id3=se
to abc.mydomain.com/xyz/se/ with url rewriting.
Here is my code in .htaccess (placed in abc folder)
Options +FollowSymLinks
RewriteEngine on
RewriteRule /xyz/([0-9a-zA-Z]+) /xyz.php?id3=$1
I'm using a hosted server.
also tried without Options +FollowSymLinks but still doesn't work. appreciate any advice from someone please.
I guess you have to remove the "/" from "/xyz.php?id3=$1".
You are in abc folder '/www/abc', and your .htaccess is in the same folder, so the "/" makes the server thinks that the page xyz.php is in the root folder which is /www and not in /www/abc !
I had the same problem and I solved it this way!
So try this code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /xyz/([0-9a-zA-Z]+) xyz.php?id3=$1
Add the domainname in your rule:
RewriteRule http://example.com/xyz/([0-9a-zA-Z]+) http://example.com/xyz.php?id3=$1
How to Redirect www.mysite.com/someurl/xyz/products to Redirect www.mysite.com/someurl/abc/products.
Please note /xyz/ to /abc/
Thank
If all is static, you just have to do it that way : (and maybe personalise the R code with R=301 or R=302...)
RewriteEngine On
RewriteRule ^someurl/xyz/products$ /someurl/abc/products [R,L]
I have example.com/xml/index.php and I want to access it with this url example.com/xml/title/ and last part would be GET var for index.php and it should show result using that var, what code should I add in my .htaccess file ?
Thanks
Try this in the .htaccess file in your document root:
RewriteEngine on
RewriteRule ^xml/([^/]+)/$ xml/index.php?var=$1