mod-rewrite

mod_rewrite error 404 if .php

允我心安 提交于 2019-12-12 07:55:39
问题 I rewrite my urls to be user friendly. For example I have a page called user.php that I rewrite to /user. But a user can still use user.php. Can I redirect to a 404 if they request a page with a .php extension? Options -MultiViews +FollowSymlinks -Indexes RewriteEngine on RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L,QSA] Thanks. 回答1: RewriteCond %{THE_REQUEST} \.php[\ /?].*HTTP/ RewriteRule ^.*$ - [R=404,L] 回答2: This should do the trick, I think: RewriteRule (.*)\.php$ path/to/your/404file

strange 401 error appears for some urls when using .htaccess to redirect http to https

好久不见. 提交于 2019-12-12 07:50:22
问题 OK, here is the 7th day of unsuccessfull attempt to find an answer why 401 error appears... Now, .htaccess in the root folder contains the only 3 strings (was simplified) and there are NO more .htaccess files in the project: RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} So, it redirects all requests to be https. It works fine for any urls, even for /administration directory. So, http://mydomain.com becomes https://mydomain.com If https:/

htaccess, Redirect all requests to https://www [closed]

北战南征 提交于 2019-12-12 07:24:07
问题 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 8 years ago . Using .htaccess, I need to redirect all requests from http://www.domain, http://domain, https://domain to; https://www.domain.com How would I do this? I don't have any subdomains. 回答1: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] RewriteCond %{http_host}

Remove string from URL using .htaccees [closed]

☆樱花仙子☆ 提交于 2019-12-12 06:49:54
问题 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 . I've set up a bit.ly link and printed it on 1000 flyers. Somehow the bit.ly target link contains some strings which shouldn't be there (https://example.com/page/%E2%80%8E instead of https://example.com/page/) Can I get rid of this string using rewrite rules in .htaccess ? Any help is appreciated! 回答1: When you

Rewrite url with query string in htaccess

你离开我真会死。 提交于 2019-12-12 06:49:21
问题 Today I try to rewrite some ugly url in order to be cache by browser! But the problem is that I have multiparameters inside the url. An example is better than a long text : the actual url with the ? and the & : http://images.mydomain.com/lib/simple-thumb.php?src=http://google.com&l=180&h=135&zc=1 And I want to use this instead : http://images.mydomain.com/lib/http://google.com/180/135/1 Should I use the rule below in my .htaccess? Options +FollowSymLinks RewriteEngine On rewritecond %{query

local URL for apache ErrorDocument directive not working in .htaccess file

本秂侑毒 提交于 2019-12-12 06:45:27
问题 I want to use local URL (relative path) to show my custom 404 error message and it doesn't seem to be working as expected. As apache documentation stated here : The syntax of the ErrorDocument directive is: ErrorDocument <3-digit-code> <action> where the action will be treated as: A local URL to redirect to (if the action begins with a "/"). An external URL to redirect to (if the action is a valid URL). Text to be displayed (if none of the above). The text must be wrapped in quotes (") if it

.htaccess mod_rewrite with multiple variable in url

喜你入骨 提交于 2019-12-12 06:27:24
问题 I'm using a search that create a query string for MySQL and show the result. The thing is that the query doesn't have the same length of variable each time a search is made. I was wondering if in .htaccess it's possible to make a mod_rewrite depending on how much variable I throw at it. Instead of having this in the URL results.php?var1=something&var2=something&var3=..... I get this results/var1/something/var2/something/var3/something... But remember that the numbers of vars can change

htaccess WWW to no-WWW not working

别来无恙 提交于 2019-12-12 06:16:54
问题 Ok I know this hasn't been answered a lot, but I've been using a lot of various different solutions but none of them are working for me. I'm trying to use mod_rewrite in my htaccess to redirect all www.domain.com to domain.com - standard enough. The site is a wordpress site, and it's always worked for me without any problems using any of the following RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] Or RewriteEngine On

Using Rewrite in .htaccess instead of Alias in httpd.conf

亡梦爱人 提交于 2019-12-12 06:16:41
问题 Trying to setup up my own Weave server on shared host, obviously I cannot modify httpd.conf file so I try to find a work-around using Rewrite module and .htaccess. Based on documentation here https://wiki.mozilla.org/Labs/Weave/Sync/1.1/Setup and https://wiki.mozilla.org/Labs/Weave/User/1.0/Setup I created .htaccess RewriteEngine on RewriteRule ^1.1(.*) server-sync/1.1/index.php/$1 [L] RewriteRule ^1.0(.*) server-sync/1.0/index.php/$1 [L] RewriteRule ^user/1.0(.*) weaveserver-registration/1.0

skip directory in URl by using Rewriting Rules

一世执手 提交于 2019-12-12 06:09:18
问题 I have a web-page with is located in example/files/page.php in my server. I would like to use Rewrite Rules in order to skip the /files directory in the URl so when the user types example/page.php to be able to view the content of the page.php. How is it possible to do so with Rewrite Rules? 回答1: Add this to the .htaccess in the root directory of your website. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d # not a dir RewriteCond %{REQUEST_FILENAME} !-f # not a file RewriteRule ^