mod-rewrite

mod_rewrite problem with relative path css/js

[亡魂溺海] 提交于 2019-12-30 08:52:04
问题 Hi I have a problem. I want to get all requests to redirect to index file in main directory and I've achieved this but there are problems with relative paths. When I put address like: mydomain.com/something it works ok as the paths are relative to the main directory. The problem is when I put something like: mydomain.com/something/somethingelse. the .htaccess file: Options FollowSymLinks RewriteEngine On # ignore anything that's an actual file RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f #

url rewriting index.php

≯℡__Kan透↙ 提交于 2019-12-30 07:48:08
问题 i have urls like http://mysite.com/index.php?p=resources http://mysite.com/index.php?p=resources&s=view&id=938 but i want urls like http://mysite.com/resources http://mysite.com/resources/view/938 instead of making hundreds of rewrite rules i wonder if it would be possible to just have one? Ive head this is possible by "getting the uri and splitting it into parts" and then just add a rewrite rule for index.php but how? could someone give an example or link a tutorial 回答1: I happen to use this

Apache mod_rewrite - prefer files over directories with pretty URLs

拟墨画扇 提交于 2019-12-30 07:43:26
问题 I want to have pretty urls so http://www.domain.com/foo will return http://www.domain.com/foo.php The issue is that there is a directory that has the same name. I have another page at http://www.domain.com/foo/bar/baz and right now my server just returns the directory listing of foo when I request http://www.domain.com/foo Pseudocode: If the request plus ".php" is a file rewrite out the file instead of the directory Actual Code: RewriteEngine On RewriteBase / RewriteCond %{SCRIPT_FILENAME}\

CodeIgniter htaccess mod_rewrite not working properly

断了今生、忘了曾经 提交于 2019-12-30 07:23:50
问题 I'm trying to make the url into http://127.0.0.1/dev/blog/welcome but when I type that it changes the url to http://127.0.0.1/dev/blog/index.php/welcome But When I do http://127.0.01/dev/blog//welcome it stays like that for some reason. my .htaccess is RewriteEngine On RewriteBase /dev/blog RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt|css) RewriteRule ^(.*)$ index.php?/$1 [L] and my config.php is configured $config[

Mod rewrite + hash tags

笑着哭i 提交于 2019-12-30 07:11:11
问题 Does mod rewrite work together with hashtags? Maybe my code is crap, but this does not seem to work: My site uses this hash tag: index.php/#p/about It works fine using regular hashtags but i want it to work with mod rewrite so i tried with: RewriteEngine on RewriteRule ^([A-Za-z0-9-]+)/?$ index.php#p/$1 [nc] My js: $(window).hashchange(function(){ alert(location.hash); } $(window).hashchange(); The out put does not work when i try the mod rewrite for example: site.com/about Any ideas? 回答1:

Redirect wildcard subdomains to subdirectory, without changing URL in address bar

*爱你&永不变心* 提交于 2019-12-30 03:39:06
问题 I've read a lot of questions and answers about this on here but none that seem to solve my specific problem. I want to redirect any subdomain to the subdirectory to match. So: x.domain.com would go to domain.com/x, and y.domain.com would go to domain.com/y - But I want to do this without the URL in the address bar changing. Here's what I have so far: Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} !^(www)\. [NC] RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com [NC]

Why is it a security risk to allow encoded slashes in a URI?

痴心易碎 提交于 2019-12-30 01:41:10
问题 I have a situation where I want encoded slashes in a URI ( %2F ), but my .htaccess rules are ignored when I make the request, sending me instead to a 404 page. I quickly found the Apache directive AllowEncodedSlashes, which I plan to turn on, but I still don't understand why it's a security risk in the first place. Couldn't anyone manually transform the encoded slashes to real slashes, if they were trying to be nefarious? (Although I can't see what harm they could do...) The application I'm

Any negative impacts when using Mod-Rewrite?

你。 提交于 2019-12-29 18:39:09
问题 I know there are a lot of positive things mod-rewrite accomplishes. But are there any negative? Obviously if you have poorly written rules your going to have problems. But what if you have a high volume site and your constantly using mod-rewrite, is it going to have a significant impact on performance? I did a quick search for some benchmarks on Google and didn't find much. 回答1: I've used mod_rewrite on sites that get millions/hits/month without any significant performance issues. You do have

How to implement dynamic subdomains in codeigniter with .htaccess?

落花浮王杯 提交于 2019-12-29 13:31:50
问题 How can I implement dynamic subdomains in codeigniter with .htaccess ? 回答1: Make sure that subdomains are enabled on your site. When you enter test.yoursite.com it should take you to the welcome page of your site. If instead it gives DNS lookup error then it means subdomains is not enabled on your site. To enable subdomains on your site add *.yoursite.com entry to the DNS Zone records. Second insert the following code in your .htaccess file and replace yoursite appropriately. <IfModule mod

CodeIgniter .htaccess - 500 Internal Server Error/ index.php remove

拜拜、爱过 提交于 2019-12-29 08:15:07
问题 I have a website like this (sub-domain) rabbani.websolocom.xyz And I have the .htaccess code like this (I used Codeigniter) : RewriteEngine on RewriteBase /rabbani RewriteCond $1 !^(index\.php|resources|robots\.txt) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-D RewriteRule ^(.*)$ index.php/$1 [L,QSA] But when I try to access my website it goes error (500 Internal Server Error). What should i do with my .htaccess file? Or any another file that wrong in my directory?