mod-rewrite

Apache2 .htaccess redirect to https not working

你说的曾经没有我的故事 提交于 2019-12-12 03:48:34
问题 I realize this is a question that was answered a lot but the other solutions are not working for me for some reason. I am trying to rewrite http as https but I am still getting 'Bad Request' when I try to browse my website using http. Here is the code in my .htaccess: RewriteEngine on RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] I have AllowOverride All in the VirtualHost config and I made sure mod_rewrite is enabled. Any help is appreciated. Let me

How can I see the value of RewriteRule or RewriteCond server variables?

ⅰ亾dé卋堺 提交于 2019-12-12 03:44:59
问题 For example, if I want to see what value is in some variable in php I do this: $foo = 'This is a variable foo'; var_dump($foo); // string(22) "This is a variable foo" echo $foo; // This is a variable foo print_r $foo; // This is a variable foo But when I write some mod_rewrite rules, for now I can only guess what value comes to the RewriteRule and what it becomes after rewriting ($0) : <Directory /public> DirectoryIndex index.php </Directory> RewriteEngine On RewriteCond %{REQUEST_FILENAME}

Removing the the query string and redirecting (rewrite rule and rewrite cond)

孤街醉人 提交于 2019-12-12 03:44:49
问题 I am currently trying to set up a rewrite rule to set up an internal redirect for a more SEO-friendly url-structure. I want to show: /find-teacher/primary-school.php instead of the sad looking: /find-teacher/subject-class-choose.php?school=primary-school After I read some posts and tutorials about the rewrite rule and rewrite cond, I came up with this: In my choose-school.php I have as a link with the nice looking url: <a href="https://www.example.com/find-teacher/primary-school.php"> Primary

how to configure apache for xampp on mac osx lion to use mod_rewrite

笑着哭i 提交于 2019-12-12 03:43:22
问题 i am totally newbie for .htaccess or apache. Don't know how it works. my url is like http://localhost/category.php?category=something i wanna get the variable value as something in category.php but wanna show the url as http://localhost/something how can i do this please help. Thank you in advance 回答1: First rule will redirect the ugly URL to the pretty URL, second rule will internally redirect the pretty URL back while not changing what the user see on the browser URL: Options

PHP - How to make pretty urls using mod_rewrite

不羁的心 提交于 2019-12-12 03:31:39
问题 I'm wondering how to make my URLs pretty and SEO friendly and also work with PHP code. Currently everything works fine (for example example.com/test/ is fine and works). However when I have error.php?id=404 , I want it to go to /error/404/ . How do I do this? My current .htaccess is... RewriteCond /%{REQUEST_FILENAME} !-d RewriteCond /%{REQUEST_FILENAME}.php -f RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php Any help please? 回答1: You can choose to let the framework handle it, or your can read more

PHP URL rewriting not working correctly

冷暖自知 提交于 2019-12-12 03:27:26
问题 I'm working on the pagination structure of my website and currently this is what the URLs look like: www.example.com/test/?page=3 I want it to look like this: www.example.com/test/3 A user in here helped me achieve this via URL extraction in PHP which fixes my issue. When I place his code in my PHP code, it doesn't fix the URL in the address bar but instead it adds the correct URL as a string in the UI. Here's a screenshot to show you what I mean. https://imgur.com/TGInt7W The first part of

URL rewrite for part of domain name

半腔热情 提交于 2019-12-12 03:25:21
问题 I feel this should be an easy fix but I'm struggling to get it done right. I have the URL: http://www.testing.com/toursgbr/my-post http://www.testing.com/toursgbr/my-post-2 I need to rewrite the URL to: http://www.testing.com/tours/gbr/my-post http://www.testing.com/tours/gbr/my-post-2 I got as far as the following: RewriteRule ^toursgbr/(.*) /tours\/gbr/$1 [L] This is what's currently in the htaccess file: RewriteEngine on ErrorDocument 404 http://www.ausweb.com.au/web-hosting AddHandler

htaccess RewriteRule fails if page not found

耗尽温柔 提交于 2019-12-12 03:21:59
问题 I'm trying to user RewriteRule in my .htaccess file to redirect example.com/page to example.com/page.php (or add the .php to any requested file that does not have an extension. I tried: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !(.*)\.php RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^([^/.]+)$ $1.php [R] #I also tried ^(.+)$ with no effect from "Spoofing" a 404 not found error with .htaccess I tried this

HTTPS and Remove index.php on CodeIgniter

ε祈祈猫儿з 提交于 2019-12-12 03:21:46
问题 I am using codeigniter framework,set .htaccess file to remove index.php and trying to enable HTTPS protocol for the server, and something happened. HTTP: Everything is okay, when I access http://www.example.com/controller/method or http://www.example.com/index.php/controller/method HTTPS: Everything is okay, when I access https://www.example.com/ index.php /controller/method Got 404 not found when I access https://www.example.com/controller/method I think that is .htaccess file problem, it is

Wildcard .htaccess rewrite subdomain to a subdirectory with subdomain as GET variable

瘦欲@ 提交于 2019-12-12 03:18:38
问题 Sample Urls: http://username1.example.com/inventory/ http://username2.example.com/profile/about http://example.com/products/category/ Rewrite to: http://example.com/subdomains/inventory/?user=username1 http://example.com/subdomains/profile/about?user=username2 http://example.com/products/category/ I think I have searched most of the internet for this. How do I rewrite the path by adding "subdomains" folder immediately after the domain and pass the subdomain as GET variable to access it via