开发者

RewriteCondition rewriteRule How to make All traffic direct to a single file?

Dear folks,

Imagine 开发者_运维问答a One Page Site

RewriteCond %{HTTP_HOST} ^1pagesite.org$  
RewriteRule ^$ 1pagesite.php [L]

Currently, the home page does present the 1pagesite.php correctly.

However, when another file is requested say, test.php which is on the server indeed, that test.php is shown!, while I would like to point ALL and ANY trafic towards 1pagesite.php for the time being. How to make this happen sothat no other file or folder/file or anything after this domain is presented and everything is directed towards 1pagesite.php?

Thanks very much for hints and suggestions to solve this puzzle. Cheers, Sam


RewriteRule ^.*(html|php)$ 1pagesite.php [L]

Note: This redirects only request to .html and .php pages


Can you try this rule:

RewriteCond %{HTTP_HOST} ^1pagesite.org$ [NC]
RewriteCond %{REQUEST_URI} !1pagesite.php$
RewriteRule \.(php|html)$ /1pagesite.php [R=302,L]

to redirect only php and html pages to 1pagesite.php


Your redirection only match ^$ that is to say only the root page (empty string).

RewriteCond %{HTTP_HOST} ^1pagesite.org$  
RewriteRule ^.*$ 1pagesite.php [L]

So every request will be redirected to 1pagesite.php page (images, css, ... as Sander said).

If you need to filter some content you can add a

RewriteCond %{REQUEST_FILENAME} !^.*\.(css|jpg)$

to enable .css and .jpg file from your / directory to be served. This can be customized for other subdirecories files etc...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜