homepage Welcome to WebmasterWorld Guest from 54.198.224.121
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
.html to .php - .htaccess. again ;-(
need to switch - but only for root directory
bluemi




msg:1305521
 2:49 pm on May 30, 2006 (gmt 0)

Yet another one with .htaccess problems. I want to switch all my .html pages to .php and for certain reasons I can't parse html pages as php. Basically this works fine for me:

Options +FollowSymlinks
rewriteengine on
rewriterule ^(.+)\.html$ [mydomain.com...] [r=301,nc]

However, this means that all my pages are going from html to php while I still have some subdirectories that I can't switch now. How would the .htacess file have to look then?

Also, I'm still using this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ [mydomain.com...] [R=permanent,L]

to make everyone typing [mydomain.com...] being automatically taken to [mydomain.com....]
Is there a way to make both work at the same time?

Thanks!

 

barns101




msg:1305522
 3:34 pm on May 30, 2006 (gmt 0)

You can stick both sets of code that you mentioned in your top-level .htaccess file but I don't think that you can shorten the two into one function (except for removing one instance of "RewriteEngine on").

As for subdirectories, I think you'll have to put an .htaccess file in each of them with similar code to what you already use, but specific to that directory, e.g.


Options +FollowSymlinks
rewriteengine on
rewriterule ^subdirectory/(.+)\.html$ http://www.mydomain.com/subdirectory/$1.php [r=301,nc]

bluemi




msg:1305523
 3:40 pm on May 30, 2006 (gmt 0)

Thanks, barns101. It seems though that

Options +FollowSymlinks
rewriteengine on
rewriterule ^(.+)\.html$ [mydomain.com...] [r=301,nc]

would change all html's into php's. For example I have a link from my main page to [mydomain.com...] which also gets changed into [mydomain.com...] This is what I have to avoid since I can't yet change the html files in some of my subdirectories.

barns101




msg:1305524
 5:06 pm on May 30, 2006 (gmt 0)

To convert only top-level files you could probably use:


rewriterule ^mydomain.com/(.+)\.html$ http://www.mydomain.com/$1.php [r=301,nc]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved