mod-rewrite

mod_rewrite not working htaccess

岁酱吖の 提交于 2019-12-24 07:41:01
问题 I have a website with 11 sub-domains.I have one main htaccess file in the public_html root folder that has the common shared traits like cache etc. I have separate htaccess files in each of the sub-domain root folders where I use mod_rewrite however I can't get it to rewrite the URL. I'm trying to change it from dundaah.com/days/content.php?day=thur to a much cleaner dundaah.com/thursday and for the sub-domains music.dundaah.com/days/content.php?day=thur to a preferred music.dundaah.com

How to prevent two links show the same content with .htaccess?

我的梦境 提交于 2019-12-24 07:37:38
问题 I have this case: /css/ <-- a folder /css/something.css <-- a file If the user accesses the folder (/css/), I want that Apache returns the file. If the user tries to access the file directly, (/css/something.css), I want that he be redirected to the folder. How can I do this without getting a loop? I've read a lot but I couldn't figure it out applying two rules, it always returns a loop. Note: this is my first question on Stack Overflow. Thank you in advance. 回答1: Put these in your htaccess

Apache rewrite string in URL - obstacle is “?” in query

我怕爱的太早我们不能终老 提交于 2019-12-24 07:36:14
问题 Want to rewrite an URL with a given user-prefix ("u-") from https://example.com/access/check?user=u-abc&pass=123 to an URL without the prefix: https://example.com/access/check?user=abc&pass=123 I tried several rules, e.g RewriteBase / RewriteRule ^access/check?user=u-(.*)$ check?user=$1 I am stuck with the "?" IF the rewrite had to apply to slightly the same, but without the "?", it indeed works: https://example.com/access/checkuser=u-abc&pass=123 RewriteRule ^access/checkuser=u-(.*)$

GET parameters not being correctly passed by RewriteRule

爱⌒轻易说出口 提交于 2019-12-24 07:31:24
问题 I wrote a simple regex for my application's API: ^api/([^/]+)/([^/.]+)\.([^$/?=&]+)(?:\?(.*))?$ this becomes /app/api/$1.php?action=$2&format=$3&$4 In the refiddle the regex works perfectly, constructing correct URLs, but the PHP script is not reporting any GET parameters apart from the action and format parameters. The .htaccess which is placed in / is AddType image/svg+xml svg RewriteEngine on #If the URL is just /api, give them the docs RewriteRule ^api/?$ /app/api/apidoc.php [L] #Example

redirect to a page without changing the url

白昼怎懂夜的黑 提交于 2019-12-24 07:14:41
问题 i have a wordpress site installed on mywebsite.com/fr/ i want the page mywebsite.com/fr/testpage/ to redirect to mywebsite.com/fr/pagewithweirdurl/ but still showing in the url mywebsite.com/fr/testpage/ i found plugins that redirect fine, but it always changes the url. i found many htaccess codes in here that do what i want, but they do it for the entire website, i just need these specific pages to do what i want . the rest is fine. so if someone could help me with an htaccess code and show

htaccess www redirect for seo friendly url

非 Y 不嫁゛ 提交于 2019-12-24 07:14:30
问题 Here's what I want: URL: http://www.domain.com/location/netherlands/amsterdam/amsterdam-airport Now, what I want is if anyone open this url without www, he should get redirected to www. Remember these are seo friendly url. I am already using MOD_REWRITE for the above url: RewriteRule ^location/([^/]+)/?([^/]*)/?([^/]*)/?$ /location.php?country=$1&city=$2&location=$3 [L,QSA,NC] Now if I do www redirect using any htaccess tricks. This is what I get: http://www.domain.com/location.php?country

Masking the folder name in the url using htaccess

牧云@^-^@ 提交于 2019-12-24 07:09:34
问题 I am trying to get my new version website online. I have already set up and tested the 301's to direct the files from www.example.com/shop to www.example.com/test. The only thing I now need to be able to do is make the url to show only www.example.com without the /test. In terms of link structure I really don't want this extra folder in there. I feel I am getting close, but have been at this for days and just can't seem to get it to work! Can someone please help? UPDATE! Is it possible that

Rewriting urls back and forth using mod_rewrite

和自甴很熟 提交于 2019-12-24 07:09:21
问题 Maybe it will seem a very simple question, my website's url are awfully written, so I want to rewrite them. So I am preparing to activate mod_rewrite. The question is the following: Suppose my url switches from site_url/index.php?page=mypage&type=mytype to site_url/mypage/mytype , what will happen if one refresh the page, is it necessary to put in the .htaccess file the converse process for proceeding to rewriting ? 回答1: You need a combination of redirect and rewriting. A draft outline of URL

htaccess - rewrite only inside folder

妖精的绣舞 提交于 2019-12-24 07:06:09
问题 I hava a folder - careers - and i want to do the rewrite only for the files of that folder, for example: mydomain.com/file.html -> its out of the folder mydomain.com/folerone/file.html -> its out of the folder mydomain.com/careers/ -> this calls the file index.php mydomain.com/careers/item -> this calls the file index.php with the $_GET variable item mydomain.com/careers/item2 -> this calls the file index.php with the $_GET variable item2 My actual .htaccess is: RewriteEngine on RewriteCond %

htaccess: rewriting unlimited subdirectories

流过昼夜 提交于 2019-12-24 07:01:18
问题 I have a fairly complex content management system I've written in PHP, which has unlimited hierarchical categories. Each category has a shortname (dynamically generated from the category title) which I using with mod_rewrite to produce clean URLs, for example http://www.mysite.com/categories/january The problem with this approach is that each category requires a unique shortname for it to work properly. This creates a problem when I have more than one category with the same name, with