Our site's sub-domain reading.domain.com has the content that we want people to see but the URL should be domain.com/reading.
I'm not an expert in URL rewriting but I tried to edit htaccess, but it only redirects the page.
We're using siteground, does hosting company has something to do with their apache configuration to make this work?
Thank you very much.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^reading/$? domain.com/reading/ [R,L]
</IfModule>
I figured it out, thanks for the insight #Panama Jack, [P] = it real does need proxy, [NC] case-sensitive, [L] use this rule one time.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^reading/?$ http://reading.domain.com/ [P,NC,L]
</IfModule>
Related
I went to make friendly urls for my web using RewriteRule as I'm using whmcs and the script is encoded. Here is what I want:
http://www.example.com/index.php?language=english
to
http://www.example.com/en/index.html
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^en/(.*)\.html$ /$1.php?language=english [L,QSA]
</IfModule>
I'm editing htaccess for the first time and don't know how to write proper urls redirectings.
I googled that problem, but there are just no answers for redirecting, only rewriting.
I have links like /?post=89 on my site and I wanted to redirect them to /stranica/89/
Could you possibly help me, how to use vars to catch that number and redirect correctly?
Tried suggested solution, didn't work. I'm seeking for something like this
Redirect index.php/?post=$ /stranica/$1/
but that code is not working.
If you have different querystring patterns in your site, you can try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)=(.*)
RewriteRule ^(.*).php /$1/%1/%2/? [R,L]
</IfModule>
This will redirect urls like /index.php?id=5 to /index/id/5/
The below code will redirect the exact url which you mentioned on your question
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^post=(.*)
RewriteRule ^index.php /index/stranica/%1/? [R,L]
</IfModule>
I have a site where regardless of what is placed instead of "www", the site still works:
ie. abc.example.com, w.example.com, wwww.example.com, ww.example.com, etc
What I need to do is redirect all of this to the "www" url.
Any help would be of great help
Regards,
Sushil
I think you're looking for something like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
This should rewrite any URL that someone goes to at "example.com" that does not begin with www to the URL with the www at the beginning. Note, you may choose to use <IfModule mod_rewrite.c> in the case the mod_rewrite is ever disabled or uninstalled.
I got a website script where it's very difficult to change page slugs.
So I thought I can do this with .htaccess.
I got my page url like - www.mysite.com/submit
So can I change this with .htaccess to www.mysite.com/create ???
Thank you!
Something as simple as your example can be easily done by .htaccess. Use this code in .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^submit/?$ create [L,NC,R]
RewriteRule ^create\$ /submit [L]
or
RewriteRule ^create$ /submit [L]
We are working on our new site, and we want to make the homepage re-direct to a subdirectory I am wondering how to do this with .htaccess as then any other page they need to go back to the old site.
These rules will forward http://yourdomain.example.com to http://yourdomain.example.com/yoursubdir/
RewriteEngine on
RewriteRule ^/?$ yoursubdir/ [L]
If you want, instead, to redirect an URL with index.php (like http://yourdomain.example.com/index.php use this rules instead.
RewriteEngine on
RewriteRule ^index.php$ yoursubdir/ [L]
In general have a look at the documentation of mod_rewrite. There are many useful and free guides around the net.
Something like this should do the trick
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/some/subdir/$1 [R=301,L]
This will rewrite the requested URI to some/subdir of newdomain.com