.htaccess

htaccess redirect from www to non-www

巧了我就是萌 提交于 2021-01-29 03:09:29
问题 I am new to this. Code from my .htaccess file goes like this: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] RewriteRule ^(.*) http://%1/$1 [R=301,NE,L] Redirect 301 /abc/ /abcnew/ I want this to redirect from www to non-www i.e., from http://www.example.com to http://example.com I copied: RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] RewriteRule ^(.*) http://%1/$1 [R

How to prevent direct access to files but allow files in webpages

血红的双手。 提交于 2021-01-28 23:11:34
问题 I'm trying to use mod.rewrite to deny direct access to files on my web server, e.g. http://domain.tld/reports/imareport.pdf or http://domain.tld/img/img1.png, and I've used the answer on this question: (htaccess) How to prevent a file from DIRECT URL ACCESS? That page suggests using mod.rewrite like this: RewriteEngine on RewriteRule \.(png|pdf|htm)$ - [F] Using mod.rewrite in this manner works fine for denying access to PDFs, but other files that are ordinarily included in a page such as

.htaccess redirect with URL friendly (mod_rewrite)

独自空忆成欢 提交于 2021-01-28 21:26:11
问题 I'm using RewriteRule in my URLs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/?$ index.php?lang=$1&page=$2 [L,QSA,NC] Now I need to create a 301 redirect. So I do that: Redirect 301 /port/reestruturacao-financeira http://website.com/port/reestruturacao-corporativa/ The result is wrong: http://website.com/port/reestruturacao-corporativa//?lang=port&page=reestruturacao-financeira How can I fix that? redirect http://website.com/port

cPanel Custom 401 Error Page “Not Displaying”

余生颓废 提交于 2021-01-28 20:24:26
问题 My problem: For some reason my custom 401 error page is not displaying on login and is just displaying the generic 401 error page: Unauthorized This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required. Additionally, a 401 Unauthorized error was encountered while trying to use an ErrorDocument to handle the request. Now in

how to redirect all subdomains to another with parameter after the trailing slash using htaccess?

和自甴很熟 提交于 2021-01-28 19:04:08
问题 If I use anything in wildcard it's redirecting me to example.com/shop . But what I want is when someone uses anything.example.com/code he redirects to example.com/shop/code . The current setting is redirecting me to example.com/code/shop if I use anything after the trailing slash in my case its code . RewriteEngine On RewriteCond %{HTTP_HOST} ^[^.]+\.(example\.com)$ [NC] RewriteRule ^ http://%1%{REQUEST_URI}/shop [R=301,L,NE] 回答1: You would seem to just need to reverse the %{REQUEST_URI}/shop

URL rewriting with .htaccess and relative paths

烂漫一生 提交于 2021-01-28 18:10:59
问题 I have a small problem with rewriting urls. I have this really simple rewrite rule: RewriteEngine on RewriteRule ^(home|apps|news|research|contribute)/$ index.php?page=$1 However, whenever I call my website like this, e.g. website.net/home/ it correctly rewrites the rule and shows the corresponding page but also messes up the css and images since it rewrites the urls for them since they are relative paths in the code. Is there any easy way to prevent this from happening? 回答1: This is because

Rewrite URL Codeigniter

无人久伴 提交于 2021-01-28 18:00:36
问题 i'm using Codeigniter for my web app, i changed the structure of the project as the following : my_Project --- application --- public_html --- resources --- system I created the folder public_html to seperate my public files from the classes .. etc, but now i have to call this url every time : my_project/public_html/controller/action i want it to be this way : my_project/controller/action I already moved out the index.php from the URL using the rewrite mode, but i can't seem to remove the

.htaccess remove duplicate part of a URL

折月煮酒 提交于 2021-01-28 17:35:55
问题 some bug in my online catalog SEF URL generation created a situation where some category slug is added to the URL twice. to fix this i would like to use .htaccess to remove the this part of the URL and have the whole URL shift up one level including URL's which also include a product under them. the duplicate occurrence is of the sub-category painting-tools under the category tools so the wrong URL looks like this: /store/items/catalog/tools/painting-tools/painting-tools or /store/items

mod_rewrite on apache - language parameter

◇◆丶佛笑我妖孽 提交于 2021-01-28 13:35:03
问题 I have searched for a solution of this problem all over the Internet, read various threads and articles about it but did come to a full solution for my - i think quite generic problem in mod_rewrite. Here is the issue: I have developed a small webapp that lets users make calculations (splitting costs after holidays "who pays to whom"). Now I have come to the point where I want to make it (especially the static pages) language dependent. What seemed like no big deal by passing a get parameter

mod_rewrite on apache - language parameter

拥有回忆 提交于 2021-01-28 13:34:09
问题 I have searched for a solution of this problem all over the Internet, read various threads and articles about it but did come to a full solution for my - i think quite generic problem in mod_rewrite. Here is the issue: I have developed a small webapp that lets users make calculations (splitting costs after holidays "who pays to whom"). Now I have come to the point where I want to make it (especially the static pages) language dependent. What seemed like no big deal by passing a get parameter