Very confusing to me, since im new.. Can someone set it up for me.. With.. www.scrimsnow.com/contact.php to www.scrimsnow.com/contact
This makes it so when users request /contact/ or /contact from your site, the url stays as /contact/ but the page they are really seeing is contact.php RewriteEngine On RewriteBase / RewriteRule ^contact/?$ /contact.php [L,NC] Code (markup):
Please explain more of what you want.. this is a good thread and we shouldn't waste pages on fluff. Why didn't it work? What happened? What are you going for?
Basically.. I want ever .php page extension to be displayed as a directory.. Ex. index.php ---- /index/ contact.php ----- /contact/ myaccount.php ---- /myaccount/ about.php ----- /about/ etc..
Ok so when a user types inthe browser site.com/contact/ the url stays site.com/contact/ but its not site.com/contact/ that is served, instead its internally redirected so that site.com/contact/ is served from site.com/contact.php This code rewrites internally any request for site.com/var/ to site.com/var.php but the url in the browser stays site.com/var/ RewriteEngine On RewriteBase / RewriteRule ^(index|contact|myaccount|about)/?$ /$1.php [NC,L] Code (markup): If a user types site.com/contact.php then hey, thats what they typed. Your only option here is to redirect requests for site.com/var.php to site.com/var/ you can do that with this code. RequestCond %{REQUEST_URI} ^/(.+)\.php$ [NC] RewriteRule ^([^\.]+)\.php$ http://www.site.com/$1/ [R,L] Code (markup): To use them both: RewriteEngine On RewriteBase / RewriteRule ^(index|contact|myaccount|about)/?$ /$1.php [NC,L] RequestCond %{REQUEST_URI} ^/(.+)\.php$ [NC] RewriteRule ^([^\.]+)\.php$ http://www.site.com/$1/ [R,L] Code (markup): If this isn't working for you either than please explain what you mean when you say it doesn't work, and explain what is seen in the url by the browser for the different stages.
If you don't need redirects... Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/$ $1.php [L]
I currently have a site with multiple PR4 and PR3 pages that are located in a subfolder www.domain.com/site/blog/ . How can I redirect all files to www.domain.com/ using the rewrite rule?
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^site/blog/([^.]+)$ http://www.domain.com/$1 [R=301,L] If you're trying to get rid of the two folders. Take out $1 if you actually want all URLs to redirect to domain.com.
Thank you. I tried it, but its not doing anything at all. The pages are still shown as www.domain.com/site/blog/page.php
Hi. I have played around and trying to do this. * redirect all URL's of http://domain.com/whatever.php to http://www.domain.com * Redirect all urls of http://www.domain.com/whatever.php to http://www.domain.com I.E = Rewrite everything to the indexpage with a 301-redirect. This is the code i am using, but i cant get it to work <IfModule mod_rewrite.c> RewriteEngine on Options +FollowSymLinks RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC] RewriteRule ^(.*) http://www.domain.com/ [L,R=301] </IfModule> I get the non-www version to redirect good, but unfortunalty i dont get the www.domain.com/whatever.php to redirect to www.domain.com
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^(.*)$ http://www.domain.com/ [R=301,L]
Thanks alot. Nintendo. I have one more question.. i try to get a string like this to 301 to the index-page domain.com/dir/C5B37243-DEAA-45D7-A131-4F5D6F3CD992.wlt?pageNo=75 domain.com/dir/E0912940-92A6-4C35-AA9A-D8CD7B38EE22.wlt?eid=176 I am using ^dir/(.*)$ http://domain.com/ The problem is that everything from the ? and after doesnt get 301:ed.. so the result becomes domain.com/?pageNo=75 domain.com/?eid=176 How do i get a redirect to cover the chars after the ? I want everything that is after /dir/ to redirect to the root. http://domain.com
? isn't very mod_rewrite friendly. I've redirected URLs with ? in them by doing.... RewriteCond %{QUERY_STRING} ^t=10285(&page=[^&]+)?$ RewriteRule ^showthread\.php$ http://www.vgchat.com/showthread.php?t=14913 [R=301,L] I'm not sure how to translate that in to your URLs.
@ apachehtaccess It did not work, I got a Internal Server Error.. @ Nintendo Yours work, but when I access my site by www.scrimsnow.com/index/ the images dont show.
Image HTML codes have to be changed as if it's the actual URL. The browsers have no ides the URLs are fake!
Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^$ http://www.nixism.com/splash.html [R=301,L]
Hey Nintendo, thanks for the answers! You could better write the above as Options +FollowSymLinks +Indexes Code (markup): But personally I only use +Indexes in my images folder. Normally I do Options +FollowSymLinks -Indexes DirectoryIndex index.php index.html Code (markup):
weird... www.nixism.com is still redirecting to the splash page.. even though I changed the htaccess file.. can someone set me up for my site to link with.. www.nixism.com and nixism.com