.htaccess - Using mod_rewrite only if a 404 would have occured -


I am in the process of converting a static website into CMS using one. I have a CMS installed in a sub directory of the public directory to avoid expiring with ugly domain names ( ) to make sure that when the request is canceled, ... is an easy way to use mod_rewrite to rewrite ... in a 404 end, there is no redirect.

An example:

  / /cms/index.html /cms/file.dat /file.dat  

if user /index.html, then they should be redirected to / cms / index.html, but if they request /file.dat they should not be not / cms / file Redirect to .dat because the file is present in the desired place

Edit Thanks for the reply

You can use it to check whether If there is an existing file that is in conformity with the requested URL, and there is no one only, then rewriting your CMS.

Here's a simple example:

  RewriteCond rewrite engine% {REQUEST_FILENAME}! -f Rewrite Rule * index.php  

If there is no existing file that is in conformity with the requested URL, then that request will be sent to index.php

< / P>

. Check the symbolic links and / or directories, BTW ... for example, here's one:

  Rewintngine on rewritecode% {REQUEST_FILENAME} -s [OR] rewrite% {REQUEST_FILENAME} - L [OR] Rewrite Convention% {REQUEST_FILENAME} -D Rivetrium ^. * $ - [NC, L] Reiratrial ^. * $ Index.php [NC, L]  

(Although it is related to ZF, it should be fine for many projects)

< / Div>

Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -