tendrousbeastie Posted October 5, 2008 Share Posted October 5, 2008 Hi All, I have a question to which I'm sure the answer is no, but I will ask anyway... I'll explain my question and then explain why I need it, as someone may be able to suggest an alternative... What I need is someway within Apache to redirect all request for page xxx.htm to xxx.php, where xxx could be any filename, but only when xxx.htm doesn't exist. If xxx.htm does exist then it should be served up as normal, and only in its absence should its PHP counterpart be served. The reason I need this is because I administer a newletter site, which so far has about 700 editions, each of which is in the filename format of newxxx.htm (where xxx is the edition number). There are various system built on top of this filename system, such as search engines and keywords tagging, that all expect the files for each edition to follow this naming sequence. Arbitrarily changing the new editions to .php would mean that these subsystems could no longer find them, and I am hoping to avoid having to rewrite these subsystems (as I didn't write them in the first place, and the guy who did was not a tidy or well commented coder). Thanks for any suggestions. Quote Link to comment Share on other sites More sharing options...
corbin Posted October 5, 2008 Share Posted October 5, 2008 RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule (.*).htm $1.php Quote Link to comment Share on other sites More sharing options...
tendrousbeastie Posted October 5, 2008 Author Share Posted October 5, 2008 Wow, thanks for the positive reply. I'll try it out tomorrow morning and let you know how it goes. Quote Link to comment Share on other sites More sharing options...
tendrousbeastie Posted October 7, 2008 Author Share Posted October 7, 2008 Bugger, it relies on ModRewrite and doesn't seem to work when used in an HTAccess file. Alas, I don't have access to the main HTTPD.conf as the site is run on a shared server and the owners are a rather reluctant to make changes. Quote Link to comment Share on other sites More sharing options...
corbin Posted October 8, 2008 Share Posted October 8, 2008 Well it can't just happen magically lol. Quote Link to comment Share on other sites More sharing options...
tendrousbeastie Posted October 8, 2008 Author Share Posted October 8, 2008 I was hoping (foolishly, I guess) that it could be done through an htaccess setting, so I could do it one a folder by folder basis. No worries, I'll have to rig something up in PHP to acheive the same end. Quote Link to comment Share on other sites More sharing options...
corbin Posted October 8, 2008 Share Posted October 8, 2008 If mod_rewrite were enabled it could be done on a folder by folder basis. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.