.htaccess

url rewriting : How to rewrite 2 urls with same number of parameters?

一曲冷凌霜 提交于 2020-01-25 02:46:05
问题 I've created some url rewriting rules. It works fine. But i have 2 pages with urls like that : actualites.php?id=xxx& alias=xxx --> Result : id-alias.php (ex : 1-article_name.php) equipe.php?id=xxx& alias=xxx --> Result : id-alias.php ((ex : 1-article_name.php) These 2 pages are different, not the same design, etc. I would like to rewrite these 2 different pages. My question is how to have two different rules for these 2 urls. Since they have 2 parameters, i have only one rule applied (the

htaccess 301 redirect with query

你离开我真会死。 提交于 2020-01-25 00:32:26
问题 I'm trying to setup an htaccess redirect with query just like this: Redirect 301 /?page=services/branddevelopment /brand-development? or this: RewriteCond %{QUERY_STRING} ^page=services/branddevelopment$ RewriteRule ^(.*)$ http://domainname/ [R=301,L] Am I missing something in here? Or a wrong syntax? It doesn't redirect the way I want it to be. Thanks! 回答1: Am I missing something in here? Or a wrong syntax? It doesn't redirect the way I want it to be. Thanks! You really didn't explain much

relative path doesn't work after adding a rewrite rule for appending trailing slash

时间秒杀一切 提交于 2020-01-25 00:07:22
问题 I have an index page placed in /forum/section1/. I have a rule to automatically redirect to the index page when I browse exampledomain.com/forum/section1/ . Sometimes when I forgot the trailing slash, it keeps loading and never goes to the index page. I have added a rule to append a trailing slash to every request: RewriteEngine on #From http://enarion.net/web/htaccess/trailing-slash/ RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ # Don't apply to images

redirect using .htaccess not working

主宰稳场 提交于 2020-01-24 21:14:30
问题 I'm trying to redirect using .htaccess from a subfolder to another domain using the following code: Redirect 301 / https://newsite.com Subfolder name is oldfolder When I click http://website.com/oldfoler , I'm redirectd to https://newsite.com/oldfolder . When I click on http://website.com/oldfoler/about-us , I'm redirected to https://newsite.com/oldfolder/about-us My .htaccess file is located in oldfolder What am I doing wrong? 回答1: That is because that is the default behavior of Redirect .

.htaccess file to remove .html from url not working

自古美人都是妖i 提交于 2020-01-24 21:02:48
问题 I'm trying to get rid of the .html in the url of pages, and I found that code in the .htaccess file is the only way doing so and I've tried nearly every method and code online but it just wouldn't work. Made an .htaccess file and put it in the public_html file. The general code I'm using is: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^.]+)$ $1.html [NC,L] But I've tried many many many other variations of the code so I think the issue isn't with the code but the way

.htaccess mod rewriterule and ampersands

て烟熏妆下的殇ゞ 提交于 2020-01-24 17:21:04
问题 I've been struggling with this for two days right now. At the moment I have the following rewrite rule: RewriteRule ^(.*)$ index.php?u=$1 [NC,L] Which ports everything behind example.com/ to index.php as the GET variable u. Which is being processed in index.php with an explode to define te different arguments being: the city (between the first slashes) en the location (the second argument) THis works perfectly for the following urls: example.com/City/location/ or example.com/City/location

How can I use SetEnvIf based on matches in the query string?

本秂侑毒 提交于 2020-01-24 16:17:20
问题 The URL I'm using is, let's say, example.com/subdir/index.php?foo=bar index.php contains this: <?php echo getenv("testenvvar"); ?> I'm setting an enviroment variable in .htaccess like so: SetEnvIf Request_URI (index) TestEnv=Worked This prints "Worked". If I change it to SetEnvIf Request_URI (bar) TestEnv=Worked , it does not. How can I do this? 回答1: To match query string you will need mod_rewrite rules instead of mod_setenv . Place this code in root .htaccess: RewriteEngine On RewriteCond %

How can I use SetEnvIf based on matches in the query string?

坚强是说给别人听的谎言 提交于 2020-01-24 16:17:12
问题 The URL I'm using is, let's say, example.com/subdir/index.php?foo=bar index.php contains this: <?php echo getenv("testenvvar"); ?> I'm setting an enviroment variable in .htaccess like so: SetEnvIf Request_URI (index) TestEnv=Worked This prints "Worked". If I change it to SetEnvIf Request_URI (bar) TestEnv=Worked , it does not. How can I do this? 回答1: To match query string you will need mod_rewrite rules instead of mod_setenv . Place this code in root .htaccess: RewriteEngine On RewriteCond %

cakephp 2 css, javascript and links not working on local machine/localhost

不羁的心 提交于 2020-01-24 14:08:17
问题 what htaccess settings should i use on the webroot folder. it seems that it's the primary culprit of why all the links in the Layout doesn't work. here is the htaccess code inside the webroot folder <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> the project is from the live server but i needed to make it work on my local machine/ localhost so that i can make some changes. but as you can

PHP $_SESSION across subdomains

北城余情 提交于 2020-01-24 12:40:21
问题 Ok so I have example.com which I then use Javascript to run XHR requests to api.example.com Previously I had the api.example.com as example.com/api but I wanted to move it to a subdomain and the sign in worked fine until I moved it to api.example.com I am testing out a sign in script and trying to keep the session live but each time it runs it clears the $_SESSION db_connect.php include_once("config.php"); ob_start(); session_start(); $db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); auth