mod-rewrite

500 Server error instead of 404 on nested urls due to mod rewrite htaccess rule(s)

▼魔方 西西 提交于 2019-12-24 17:12:18
问题 I have a site with custom .htaccess file that handles few things: 1) It treats urls without ".php" extensions as if it has ".php" in the end. 2) It redirects http:// and http://www. urls to https://www. Here is the .htaccess file: ErrorDocument 404 /404.php Options -MultiViews RewriteEngine On ## add www and turn on https in same rule RewriteCond %{HTTP_HOST} !^www\. [NC,OR] RewriteCond %{HTTPS} !on RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC] RewriteRule ^ https://www.%1%{REQUEST_URI} [R

htaccess - how to capture the current rewrited url?

大城市里の小女人 提交于 2019-12-24 17:12:02
问题 I want to capture the current rewrited url via .htaccess in order to create to a custom HTTP Link header. the script url : http://localhost/index.php the rewrited url : http://localhost/news the htaccess: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(news)$ index.php?&m=$1 [NC,L,QSA] RewriteRule ^(.*) - [E=ORIGPROTO:http] RewriteRule ^(.*) - [E=ORIGURI:%{HTTP_HOST}] RewriteRule ^(.*) - [E=ORIGQRY:%{REQUEST_URI}] the output: ORIGPROTO = http ORIGURI =

Mod_rewrite clarification question. Only for dynamic urls?

只愿长相守 提交于 2019-12-24 16:42:34
问题 I've been asked to develop a mod_rewrite to change http://www.example.com/health-and-fitness-tips/999/ into http://www.example.com/health-and-fitness-tips/how-do-I-lose-10kg-in-12-weeks/ where 999 is the id and How do I lose 10kg in 12 weeks is the title . Is this even remotely possible or is mod_rewrite only for changing something like http://localhost/siteengine/products.php?id=123 into http://localhost/products/123 ??? 回答1: i'm guessing the answer meder gave is the one you're looking for

htaccess to rewrite file in subfolder (2nd level) to folder (1st level)

ⅰ亾dé卋堺 提交于 2019-12-24 16:40:20
问题 Currently, I'm using the below htaccess code to load http://www.domain.com/folder/file.php from http://www.domain.com/file, removing the folder name "/folder/", and the file extension ".php", from the URL. Options +FollowSymLinks RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/folder%{REQUEST_URI}\.php -f [OR] RewriteCond %{DOCUMENT_ROOT}/folder%{REQUEST_URI} -d RewriteRule ^(.*)$ /folder/$1.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] Now, I'm trying to do

.htaccess Pretty URL rewrite for PHP pages in a subfolder?

谁都会走 提交于 2019-12-24 16:39:35
问题 I've got the following directory setup: http://www.mysite.com/public/ I'm using the following rewrite to remove the 'public' folder from visible URLs: #rewrite the URL to display the subdirectory as the main directory for all links RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com RewriteCond %{REQUEST_URI} !^/public Rewriterule ^(.*)$ /public/$1 [L] This works great, and redirects everything correctly. However, I also want to rewrite some of the dynamic pages that live in the 'public' subfolder

make 301 redirect from old asp page to wordpress php [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-24 16:39:00
问题 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 . can anyone help me make a 301 redirect from an asp page: http://www.maribowl.dk/bowling.asp?Page=Caf%E9+Menu to my new wordpress site: http://www.maribowl.dk/cafemenu/ can this be done in an .htaccess file on the wordpress site or where should I paste it in? 回答1: Place this code in your DOCUMENT_ROOT/.htaccess

.htaccess force HTTPS

◇◆丶佛笑我妖孽 提交于 2019-12-24 16:28:18
问题 I've been struggling for a while to find a method of using .htaccess to force HTTPS on my website. Any way I've tried has resulted in a redirect loop. I found a PHP alternative and amended it to suit my webserver, but I'd like the .htaccess equivalent if anybody could help. if ($_SERVER['HTTP_X_FORWARDED_PROTO'] != "https") { header("HTTP/1.1 301 Moved Permanently"); $location = "https://" . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]; header("Location: $location"); exit; } 回答1: You can use

htaccess change webroot and protect files

时光总嘲笑我的痴心妄想 提交于 2019-12-24 16:27:36
问题 I have always ensured my application code, configuration files, logs, etc, are stored OUTSIDE of the webroot. It's just common sense. So, my project structures look something like... /app/ /config/ /web/ My client is already with godaddy, so I stupidly registered a basic linux hosting package with them, before realising they don't let you access one level above your webroot OR change your webroot to one level lower. Their tech support guy just told me to make a new folder in there and call it

Redirect Old URL to New URL open cart using htaccess

江枫思渺然 提交于 2019-12-24 16:05:08
问题 I want to redirect 301 old url to new url. my old url is; http://www.domainname.com/special and new url is; http://www.domainname.com/offers I tried this code: redirect 301 /http://www.domainname.com/special http://www.domainname.com/offers But still now it's not redirecting & taking me to the old URL which does'nt exist. 回答1: Try this : Redirect 301 /special /offers Second argument of Redirect Directive is the URL Path, it doesn't start with Scheme and hostname. 回答2: There are various ways

Mod_rewrite http->https redirect EXCEPT one URL

99封情书 提交于 2019-12-24 16:00:52
问题 OK, so I'm trying to do this: !www -> www http -> https EXCEPT /[a-f0-9]{11}/ https://www.domain.com/[a-f0-9]{11}/ -> http://www.domain.com/[a-f0-9]{11}/ map to controller: index.php?(uri) e.g. /controller/action/id -> index.php/controller/action/id Summary: all URLs should be https://www.domain.com/(.*) except /[a-f0-9]{11}/, which should be forced to http only. I have an old set of rules (see below) which don't look very clean. I've tried adding to them to account for /[a-f0-9]{11} and it