mod-rewrite

Force a URL-path for mod_rewrite's RewriteRule Substitution

走远了吗. 提交于 2020-01-14 08:43:27
问题 When performing rewrites with mod_rewrite's RewriteRule , the substitution is evaluated and a guess made as to whether it's a URL or a file-system path, based on whether the root directory of the substitution exists on the file system. Here's the relevant section from the documentation: URL-path Note that mod_rewrite tries to guess whether you have specified a file-system path or a URL-path by checking to see if the first segment of the path exists at the root of the file-system. For example,

net::ERR_INCOMPLETE_CHUNKED_ENCODING

狂风中的少年 提交于 2020-01-14 07:16:48
问题 I use .htaccess to rewrite url from someurl.com/ to someurl.com/public/. First .htaccess in www root contains this: DirectoryIndex ./public/ RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./public/$1 [QSA] and second one in folder /public/ contains this: DirectoryIndex _main.php RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./?params=$1 [QSA] And the problem is when I open

net::ERR_INCOMPLETE_CHUNKED_ENCODING

感情迁移 提交于 2020-01-14 07:15:01
问题 I use .htaccess to rewrite url from someurl.com/ to someurl.com/public/. First .htaccess in www root contains this: DirectoryIndex ./public/ RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./public/$1 [QSA] and second one in folder /public/ contains this: DirectoryIndex _main.php RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*)$ ./?params=$1 [QSA] And the problem is when I open

htaccess mod_rewrite no duplicate content

社会主义新天地 提交于 2020-01-14 05:41:10
问题 I have written a rewrite rule to get all pages looking like dealer_listings.php?territory=arizona to be accessible like this wholesale-parts/arizona/ I would like the ugly url to redirect to the seo friendly one as well. Options -MultiViews RewriteEngine on <FILES .htaccess> order allow,deny deny from all </FILES> RewriteRule ^([^/\.]+)/+([^/\.]+)/([^/\.]+)/?$ bussiness_profile.php? what=$1&type=$2&dealer=$3 [L] rewriterule ^wholesale-parts/([^/\.]+)/?$ dealer_listings.php?territory=$1 [R=301

How to I add a wildcard subdomain redirect to a subdirectory in htaccess?

不羁的心 提交于 2020-01-14 05:05:13
问题 My old subdomain urls look something like: www.newyork.website.co.uk I want to redirect it now to: www.website.com/city/newyork However I have over 2,000 cities and just want to add a wildcard redirect. How do I go about doing this in my htaccess file? e.g. www.*.website.co.uk redirects to www.website.co.uk/city/* THis is so far over myhead but this is what I have tried to muddle together: RewriteEngine On RewriteCond %{HTTP_HOST} !^domain\.co.uk$ [NC] RewriteRule ^(.*)$ http://www.domain.co

Redirect HTTPS to HTTP if querystring parameter is absent via htaccess

对着背影说爱祢 提交于 2020-01-14 04:48:25
问题 I would like to redirect HTTPS to HTTP only if the following querystring parameters are absent: https://www.example.com/index.php?p=login https://www.example.com/index.php?p=signup https://www.example.com/index.php?p=cart https://www.example.com/index.php?p=one_page_checkout That is, any querystring other than these should redirect from HTTPS to HTTP. I want to make sure only my checkout path is HTTP. Can this be done simply using .htaccess with RewriteCond and RewriteRule ? 回答1: Add this to

Error 500 with .htaccess edits but mod_rewrite is loaded [closed]

瘦欲@ 提交于 2020-01-14 04:47:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . as of title, I'm having problems with my .htaccess file, everything should be set fine, but has I write something as basic as RewriteEngine on it starts giving me that nice 500 Internal Server Error. I'm hosting on localhost on an Apache server (UNIX) Obviously I triple checked that everything is set fine, and

mod rewrite beginner questions

落爺英雄遲暮 提交于 2020-01-14 04:42:32
问题 How would I rewrite script.php?id=3295 to script/3295?? and Im also wondering if someone could explain what these 3 RewriteConds does: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l Thank you very much 回答1: As I rather think that you want to rewrite requests of /script/3295 to /script.php?id=3295 and not the other way round, try this: RewriteRule ^/script/([0-9]+)$ /script.php?id=$1 But if you really want to rewrite script.php?id

generic non-www to www, and non-http to https

≡放荡痞女 提交于 2020-01-14 04:34:08
问题 I have the following code for my .htaccess file that I've picked up from here and tried adapting it as I understand from .htaccess, yet I can't seem to get it to work (or maybe the browser has cached it but I can't seem to clear it). Options -Indexes Options +FollowSymlinks <IfModule mod_rewrite.c> ########## FORCE SSL ########## RewriteEngine On RewriteBase / # Non-secure requests to www.domain.com should redirect to https://www.domain.com RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST}

Removing .php with mod_rewrite

谁说胖子不能爱 提交于 2020-01-14 02:06:22
问题 I want to rewrite all my URLs to hide the .php extension. A general rule that adds .php to all URLs obviously won't do, so I want this rule to be conditional on the fact that There is no file nor directory that matches the URL After adding the .php , there is a match I've arrived at these rewriting rules: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L] The first two take care of checking whether the