mod-rewrite

.Htaccess rules to redirect respective HTTP links to HTTP and HTTPS to HTTPS?

我只是一个虾纸丫 提交于 2019-12-11 20:06:10
问题 First, here's the .htaccess rule I currently use: Options +FollowSymLinks RewriteEngine on RewriteRule (.*) http://example.com/$1 [R=301,L] This is great, and redirects every link of my old domain to the very respective link in new domain. That is, http://olddomain.com/1.html is redirected to http://example.com/1.html and so forth. But it doesn't redirect https://olddomain.com/1.html to https://example.com/1.html And just so you know I tried, below are the rules I also happened to test.

mod_rewrite works on localhost but not on server

人盡茶涼 提交于 2019-12-11 19:48:26
问题 AS the title says, my rewrite rules does not work when I upload it to my server (Ubuntu LTS). The .htaccess-file is in play, but does nothing. mod_rewrite is loaded, I've verified that several ways. I tried writing rubbish text in the .htaccess file and got a 500 internal error, so the file seems to be in the loop. The virtualHost configuration has "allowOverride All". The .htaccess file consists of a series of rewrite rules, such as: RewriteRule ^webshop$ index.php?page=webshop [QSA]

Why .htaccess mod_rewrite does not show a real directory

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 19:33:18
问题 I've written the codes below inside a .htaccess file. RewriteEngine On Options +FollowSymLinks RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?p=$1&id=$2 [NC,QSA,L] RewriteRule ^([^/\.]+)/?$ index.php?p=$1 [NC,QSA,L] I have made a control panel for administrator of my website inside admin directory too. The problem is that when I want to enter to control panel from this address www.site.com/admin , it does not show what I

mod_rewrite: rewriting environment in url in Symfony2

偶尔善良 提交于 2019-12-11 19:30:44
问题 I created a new environment in Symfony2 called demo which is controlled by app_demo.php . I want to rewrite the url using htaccess tu use: http://myhost/demo/ instead of http://myhost/app_demo.php/ Which RewriteRule should i add to my .htaccess? EDIT: I was already using the way user janek suggests for removing the app.php from the url. But when i add this set of rules for the app_demo.php i still get 404: DirectoryIndex app_demo.php <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %

Redirect all to base domain

淺唱寂寞╮ 提交于 2019-12-11 19:18:32
问题 I would like to redirect all pages like: www.mydomain.com/test www.mydomain.com/test2/test3 and so on ... to always base www.mydomain.com How can i do this? RewriteCond %{HTTP_HOST} ^www.mydomain.com RewriteCond %{THE_REQUEST} ^/(.*)$ RewriteRule (.*) http://%{HTTP_HOST} [L,QSA,R=301] wont work 回答1: RedirectMatch 301 ^/ http://www.mydomain.com/ It will redirect everything to your new domain. This will work if you have mod_alias 回答2: Please try this : RewriteEngine On RewriteCond %{REQUEST_URI

Apache redirect localhost to localhost/abc/def/

馋奶兔 提交于 2019-12-11 19:17:03
问题 I want to map "localhost/" to "localhost/abc/def/" in apache. How should I edit .htaccess to achieve this? 回答1: If you want to redirect just this one URL, use this simple RewriteRule RewriteEngine on RewriteRule ^$ /abc/def/ [R,L] If you want to move the whole site instead, you can use Redirect Redirect / /abc/def/ 来源: https://stackoverflow.com/questions/15455868/apache-redirect-localhost-to-localhost-abc-def

ignore last directory if it is the second directory mod_rewrite

旧时模样 提交于 2019-12-11 19:16:01
问题 I am attempting to setup a mod_rewrite that will do the following www.mysite.com/dir/ignoreMe will map to www.mysite.com/dir however in the browser the url will still appear to be www.mysite.com/dir/ignoreMe if the url entered is simply www.mysite.com/dir the rewrite shouldn't do anything. This way I can use the last/ second directory as if it was a GET query string 回答1: RewriteRule ^([^/]*)/([^/]+)$ /$1 来源: https://stackoverflow.com/questions/4453730/ignore-last-directory-if-it-is-the-second

Creating static, SEO friendly URLs with mod-rewrite

▼魔方 西西 提交于 2019-12-11 19:13:30
问题 Okay I have revised a previous question to make my intentions more clear and hopefully to help others wishing to do similar things. Let's say I have a digital download store, I want my URL's to look like this: downloads.com/music/this-song-name/3873 // A url to a unique track downloads.com/music/featured-stuff // A url that links to unique content downloads.com/music // The homepage for that section I could also have a url like this downloads.com/videos/this-video/3876 etc. Now, Server side,

mod_rewrite rules and content negotiation

与世无争的帅哥 提交于 2019-12-11 19:09:02
问题 I am relatively new to mod_rewrite, but have a site which I would like to have "pretty urls." Similarly to SO :). I am attempting to have things like: "http://www.whatever.com/search/test" get rewritten to "http://www.whatever.com/search.php?q=test" and have had some limited success. I believe that content negotiation is getting in my way... For starters here's my test .htaccess file: RewriteEngine on RewriteBase /~user/mysite/ RewriteRule ^search$ search/ [R] RewriteRule ^search/([^/]*)/?$

Redirect to different domain and URL structure

风格不统一 提交于 2019-12-11 19:04:11
问题 I need to permanently redirect part of a website to a different domain and URL structure. Everything that matches: example.com/year/month/day/page-name/ and www.example.com/year/month/day/page-name/ Needs to redirect to: www.sample.com/sub/sub2/year/month/page-name/ For example: example.com/2013/11/09/a-great-page/ should permanently point to: www.sample.com/sub/sub2/2013/11/a-great-page/ But I don't want to redirect any other pages on the site: example.com/a-random-page Shouldn't redirect