Calculated File check?
4 posts
• Page 1 of 1
Calculated File check?
They keep asking me to put in 'vanity' URLs where say someone typed in 'contact-us' it would go to the 'contact-us.html' page.
I would love to just have this work for all pages where it simply checks:
- Does the file exist?, simply load the page.
- Does the file with the added '.html' extension exist?, then load it (combine it with the first check?)
- Then continue with any additional rules...
Possible?
I would love to just have this work for all pages where it simply checks:
- Does the file exist?, simply load the page.
- Does the file with the added '.html' extension exist?, then load it (combine it with the first check?)
- Then continue with any additional rules...
Possible?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Calculated File check?
Peace of cake:
Which line by line would mean:
Regards
Andrew
- Code: Select all
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}.asp !-f
RewriteCond %{REQUEST_FILENAME}.asp !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [NC,L]
Which line by line would mean:
Is it a file? no
Is it a directory? no
If we add .html is it a file? yes
Rewrite to html file with the same name as requested URL
Regards
Andrew
Re: Calculated File check?
Thanks, It seems all too straight forward. Appreciate it!
I questioned the need for he first two Conditons and just ended up putting this at the end of the file which seems to work as you indicated.
Just removed the NC as we're just looking for any character and want to rewrite the URL.
Is there ever a concern with doing too many 'file related' rules? Another reason to leave the first two out?
I questioned the need for he first two Conditons and just ended up putting this at the end of the file which seems to work as you indicated.
- Code: Select all
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [R,L]
Just removed the NC as we're just looking for any character and want to rewrite the URL.
Is there ever a concern with doing too many 'file related' rules? Another reason to leave the first two out?
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Calculated File check?
I wouldn't say that there's a concern about it. However, when a list of rules grows, the chance of getting a conflict rises.
Regards
Andrew
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests