mod-rewrite

relative path doesn't work after adding a rewrite rule for appending trailing slash

时间秒杀一切 提交于 2020-01-25 00:07:22
问题 I have an index page placed in /forum/section1/. I have a rule to automatically redirect to the index page when I browse exampledomain.com/forum/section1/ . Sometimes when I forgot the trailing slash, it keeps loading and never goes to the index page. I have added a rule to append a trailing slash to every request: RewriteEngine on #From http://enarion.net/web/htaccess/trailing-slash/ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ # Don't apply to images

Friendly URLs with .htacces weird response form my web hosting… HELP

十年热恋 提交于 2020-01-24 20:56:07
问题 I just wanted that when this is inserted in the URL: http://website.com/pelicula/0221889/ http://website.com/pelicula/0221889/posters/ It really goes to this (in background): http://website.com/index.php?ctrl=pelicula&id=0160399 http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters So I put this in my .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L] <

How can I use SetEnvIf based on matches in the query string?

本秂侑毒 提交于 2020-01-24 16:17:20
问题 The URL I'm using is, let's say, example.com/subdir/index.php?foo=bar index.php contains this: <?php echo getenv("testenvvar"); ?> I'm setting an enviroment variable in .htaccess like so: SetEnvIf Request_URI (index) TestEnv=Worked This prints "Worked". If I change it to SetEnvIf Request_URI (bar) TestEnv=Worked , it does not. How can I do this? 回答1: To match query string you will need mod_rewrite rules instead of mod_setenv . Place this code in root .htaccess: RewriteEngine On RewriteCond %

How can I use SetEnvIf based on matches in the query string?

坚强是说给别人听的谎言 提交于 2020-01-24 16:17:12
问题 The URL I'm using is, let's say, example.com/subdir/index.php?foo=bar index.php contains this: <?php echo getenv("testenvvar"); ?> I'm setting an enviroment variable in .htaccess like so: SetEnvIf Request_URI (index) TestEnv=Worked This prints "Worked". If I change it to SetEnvIf Request_URI (bar) TestEnv=Worked , it does not. How can I do this? 回答1: To match query string you will need mod_rewrite rules instead of mod_setenv . Place this code in root .htaccess: RewriteEngine On RewriteCond %

How to remove php extension and also redirect extensions to no extension form

妖精的绣舞 提交于 2020-01-24 07:46:50
问题 How can I have this in my htaccess: /page.php => redirects to /page /page => shows the page.php /index => redirects to root And how to remove trailing slashes from all URLs, specially the root one? Although, I'm not familiar enough with Apache configs, but I could find these codes: # To remove .php extension RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # To remove trailing slashes RewriteRule ^(.*)/$ /$1 [L,R=301] # To redirect

How to remove php extension and also redirect extensions to no extension form

跟風遠走 提交于 2020-01-24 07:46:08
问题 How can I have this in my htaccess: /page.php => redirects to /page /page => shows the page.php /index => redirects to root And how to remove trailing slashes from all URLs, specially the root one? Although, I'm not familiar enough with Apache configs, but I could find these codes: # To remove .php extension RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # To remove trailing slashes RewriteRule ^(.*)/$ /$1 [L,R=301] # To redirect

How to remove php extension and also redirect extensions to no extension form

这一生的挚爱 提交于 2020-01-24 07:46:05
问题 How can I have this in my htaccess: /page.php => redirects to /page /page => shows the page.php /index => redirects to root And how to remove trailing slashes from all URLs, specially the root one? Although, I'm not familiar enough with Apache configs, but I could find these codes: # To remove .php extension RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # To remove trailing slashes RewriteRule ^(.*)/$ /$1 [L,R=301] # To redirect

apache mod_rewrite equivalent for node.js?

浪尽此生 提交于 2020-01-24 02:33:10
问题 Is there an equivalent module for Node.js that does what Apache's mod_rewrite does? or is there a standard language construct that provides equivalent functionality? I'm just getting started with Node and looking to convert my server to this platform. 回答1: As suggested by the previous answers you need to write it yourself; the two previous answers were both more orientated towards handling different paths specially. You might find my node reverse proxy helpful, as it has a lot of code for

Redirect all HTTP urls to HTTPS for frontend in magento

こ雲淡風輕ζ 提交于 2020-01-24 01:09:08
问题 I want to redirect all http urls to https in magento, but for front-endonly. In magento we have a setting to use secure urls for front-end as explained in this link: https://www.siteground.com/tutorials/magento/magento_ssl.htm but that applies to only pages shown after login or checkout. I have applied following code in my .htaccess file: RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L] It is working ok, but it is redirecting Admin panel urls to https as well. I

How to execute php files with .html extension?

家住魔仙堡 提交于 2020-01-23 13:05:37
问题 i have problem with my site, when i try to convert php to html, i got this error Not Found and this is .htaccess RewriteEngine on RewriteRule ^(.*)\.php$ /ver1/$1.html [R=301,QSA,L] all files in folder ver1 i see this post .php url to .html url but not work with me i just need convert php to html and if i go to index.php i go to index.html and make all url html 回答1: Rename your .php file to .html and add this line in your .htaccess AddType application/x-httpd-php .html .htm 回答2: You need to