mod-rewrite

Directing Non-Slash URL to Slash

☆樱花仙子☆ 提交于 2021-02-10 11:12:14
问题 When I enter the website.com/seo link, I want to make a 301 redirect to the website.com/seo/ link. However, I don't want it to be broken in the codes I wrote in the current htaccess. my htacces codes: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 回答1: Use only one of these, do not use together! Try: RewriteEngine

Directing Non-Slash URL to Slash

北战南征 提交于 2021-02-10 11:03:29
问题 When I enter the website.com/seo link, I want to make a 301 redirect to the website.com/seo/ link. However, I don't want it to be broken in the codes I wrote in the current htaccess. my htacces codes: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 回答1: Use only one of these, do not use together! Try: RewriteEngine

Run PHP pages without an extension

蹲街弑〆低调 提交于 2021-02-10 07:39:28
问题 I want to run my PHP web pages on an apache web server without the .php extension. So I added the following code: RewriteEngine on RewriteBase / Rewritecond %{REQUEST_URI} !(^/?.*\..*$) [NC] RewriteRule (.*)$ $1.php [NC] in the .htaccess file. This solves my problem but another problem arises. I cannot view the content of any directory (i.e. the file contained in the directory). Please provide me an alternate RewriteRule without this problem. 回答1: You need to make sure that the request URI

.Htaccess redirect to 404 page when certain files doesn't exist

夙愿已清 提交于 2021-02-10 07:15:48
问题 I've been working with my own MVC system for a while now and it works great! I use this in my .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?page=$1 [QSA,L] Now, when a page (controller) doesn't exist, I redirect to /error (in the index.php file) . But there are some scenarios when a picture will be deleted in a folder, and still be printed in the html page. This will

.Htaccess redirect to 404 page when certain files doesn't exist

混江龙づ霸主 提交于 2021-02-10 07:15:41
问题 I've been working with my own MVC system for a while now and it works great! I use this in my .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?page=$1 [QSA,L] Now, when a page (controller) doesn't exist, I redirect to /error (in the index.php file) . But there are some scenarios when a picture will be deleted in a folder, and still be printed in the html page. This will

.Htaccess redirect to 404 page when certain files doesn't exist

点点圈 提交于 2021-02-10 07:14:56
问题 I've been working with my own MVC system for a while now and it works great! I use this in my .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?page=$1 [QSA,L] Now, when a page (controller) doesn't exist, I redirect to /error (in the index.php file) . But there are some scenarios when a picture will be deleted in a folder, and still be printed in the html page. This will

.Htaccess redirect to 404 page when certain files doesn't exist

懵懂的女人 提交于 2021-02-10 07:14:27
问题 I've been working with my own MVC system for a while now and it works great! I use this in my .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?page=$1 [QSA,L] Now, when a page (controller) doesn't exist, I redirect to /error (in the index.php file) . But there are some scenarios when a picture will be deleted in a folder, and still be printed in the html page. This will

.Htaccess redirect to 404 page when certain files doesn't exist

大憨熊 提交于 2021-02-10 07:14:24
问题 I've been working with my own MVC system for a while now and it works great! I use this in my .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?page=$1 [QSA,L] Now, when a page (controller) doesn't exist, I redirect to /error (in the index.php file) . But there are some scenarios when a picture will be deleted in a folder, and still be printed in the html page. This will

Is it possible to query a database using a value passed in a URL, and write the result of the query to the URL using mod_rewrite?

限于喜欢 提交于 2021-02-08 20:56:11
问题 Is it possible to use mod_rewrite to write an htaccess rule that takes a url parameter value (for example: id=1, where 'id' is the parameter, and '1' is the parameter value), query a database with the parameter value specified, and then write the value returned from the query as a part of the url of the requested page? I know the basics of mod_rewrite, for example rewriting a url that appears like: www.example.com/item.php?id=1 to the following: www.example.com/item/1 An example of what I

mod-rewrite subdomain to path in primary domain

自作多情 提交于 2021-02-08 10:32:53
问题 I have content from a different server on a subdomain that I would like to use as a subdirectory. Everything from sub.domain.com should be accessible to domain.com/sub I would like sub folders to work as well ex: sub.domain.com/about should be domain.com/sub/about Here's my current .htaccess contents <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(sorry).* - [NC,L] RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] </IfModule> Any help appreciated. Thanks! 回答1: Enable