mod-rewrite

Rewriterule for CodeIgniter not working

主宰稳场 提交于 2020-01-01 10:48:11
问题 I have installed a clean Apache2 (plus PHP & MySQL) server and enabled the mod_rewrite in the apache config. I added the .htaccess file to remove the index.php from the url as described in the CodeIgniter wiki. RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] I placed this file in the website's root. When I try to access the url mydomain.local/index.php/welcome then I get the default page of CodeIgniter. But when I try to access the same

.htaccess not working on my Ubuntu 14.04 Distribution

走远了吗. 提交于 2020-01-01 07:06:50
问题 I have just configured my LAMP stack on my Ubuntu 14.04 distribution and want to set .htaccess up to serve a website. I followed the tutorial https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file and configured a virtual host for my domain, however I am still unable to use the .htaccess file in my projects root, whenever I try to serve a page I get a 404 error . The .conf file for my domain looks like: <VirtualHost *:80> ServerAdmin alexmk92@live.co.uk ServerName

Is PHP allowed to modify .htaccess file in current folder?

左心房为你撑大大i 提交于 2020-01-01 06:18:08
问题 I have a PHP web app located on shared hosting . My goal is to modify .htaccess file from PHP code when the PHP page is running. I need that .htaccess to insert a couple of mod_rewrite lines into it. The problem is that on Windows+Apache I can dynamically modify .htaccess file but the same code on Linux reports a problem when I try to access this file in any way (copy or fopen): "failed to open stream: Permission denied" I have given .htaccess file 777 permissions - still no result. WHat

htaccess rewrite only if file doesn't exist

泪湿孤枕 提交于 2020-01-01 06:09:13
问题 Using .htaccess mod rewrite, I would like to rewrite a url, check if that file exists, and if not rewrite again to another url using part of the original url which was removed during the 1st re-write. For example, if the original url is this /images/3001/zebra.jpg I would like to check if the file exists /images/cached/zebra.jpg and serve it if it does exist. And if not I would like to rewrite to /image.php?id=3001 Thanks very much, Phil 回答1: In the htaccess file in your document root, add

mod_rewrite with exceptions

余生长醉 提交于 2020-01-01 05:20:09
问题 For redirecting every request on my server to a secure connection I use RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://mywebsite.com/$1 [R,L] which works perfect. However I need two paths not to be redirected. Say when I access http://www.mywebsite.com/page1/test http://www.mywebsite.com/page2 I want to go to exactly that path. Is that possible with mod_rewrite? 回答1: Try something like this: RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !/page1/test RewriteCond %{REQUEST

Allowing only certain files to view by .htaccess

喜夏-厌秋 提交于 2020-01-01 04:24:07
问题 i have almost 20 pages on server, but i want only a file named abc.php, which users can watch. i want if user forcefully open the other files like //example.com/some.php .htaccess shows 403 error. <Files ~ "^(?!(changepwd|login|register|remind|securitycode|registersuggest)\.php$).*(\.php)$"> AuthName "Reserved Area" AuthType Basic AuthUserFile path_to/.htpasswd AuthGroupFile path_to/.htgroup Order Deny,allow Require group allowed_groups </Files> this is the way i am currently using, but i

rewriterule in htaccess to match certain file extensions

杀马特。学长 韩版系。学妹 提交于 2020-01-01 04:17:12
问题 How can I look for an instance for certain file extensions, like .(jpg|png|css|js|php), and if there is NOT a match send it to index.php?route=$1. I would like to be able to allow period's for custom usernames. So, rewrite http://example.com/my.name to index.php?route=my.name Current setup: .htaccess: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^.]+)$ index.php?route=$1 [QSA,L] </IfModule> What

cakephp & httpd.conf issues on windows based apache server (wamp)

余生长醉 提交于 2020-01-01 03:35:13
问题 So, i was wondering if some one could clarify following occurrence and maybe suggest how I could tackle this. sorry for the weird coloring of the code Let me explain the set up first. I have wamp server installed and it is located physically on one hd and then my development files are located on separate hd. So i have added alias to access specific dev folder in httpd.conf i have following ServerRoot D:/Program Files/wamp/bin/apache/apache2.2.11 Listen 80 ServerName localhost:80 DocumentRoot

Using mod_rewrite to convert paths with hash characters into query strings

瘦欲@ 提交于 2020-01-01 01:29:47
问题 I have a PHP project where I need to send a hash character (#) within the path of a URL. (http://www.example.com/parameter#23/parameter#67/index.php) I thought that urlencode would allow that, converting the hash to %23 But now I see that even the urlencoded hash forces the browser to treat everything to the right as the URL fragment (or query). Is there a way to pass a hash through, or do I need to do a character substitution prior to urlencode? Edit to add (Sep 19 2017): It turns out that I

How to Simulate & Test URL rewrite rule in Apache 2, when on sharehosting RewriteLog is disabled/unallowed in .Htaccess?

我们两清 提交于 2020-01-01 01:17:13
问题 How to Simulate & Check a URL rewrite rule in Apache 2, when on sharehosting RewriteLog is disabled and or NOT allowed to be set in .Htaccess? In other words, are there any tools/simulators to test an url rewrite independantly of hosting, to check see for possibel Rewrite loops etc? Thanks! 回答1: I enjoy using http://htaccess.madewithlove.be However, things like RewriteCond %{REQUEST_FILENAME} !-f won't work, yet. 回答2: I use Mod Rewrite Generator to generate and test my RewriteRule. It takes