Can anyone explain to me why this rewrite rule doens't work:
RewriteRule ^architecture/([a-zA-Z_]+)/(.*).html$ web/index.php?field=1&sub=$1&name=$2
on this url: http://localhost/greenlinked1-6.com/architecture/projects/84-test-deeplink-test.html
And what I should do to get it working.
I've tried to find the answer in several articles but I can't figure it out.
Your .htaccess file should be placed in the directory greenlinked1-6.com. Make sure there are no conflicting rules, like this:
RewriteRule ^(.+)$ $1 [L]
# This line will never be be matched
RewriteRule ^architecture/([a-zA-Z_]+)/(.*).html$ web/index.php?field=1&sub=$1&name=$2
check that u havn't used RewriteBase / just remove & try again...
Related
Anyone can help to have "domain.com/store1/any-product" instead of "store1.domain.com/any-product"? The second is what I have and the first is what I would like to have.
Maybe some .htaccess code added? Anything else, please?
You should be able to achieve that by using the following rule in your .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^store1.example.com
RewriteRule ^(.*)$ http://example.com/store1/$1 [L,NC,QSA]
What the above does is if the condition for store1.example.com is met, then it will rewrite the URL to example.com/store1. This will also work for any other directories you have as a part of it. So it would become example.com/store1/about for example.
Make sure you clear your cache before you test this.
I'm having trouble with an Apache mod_rewrite. My .htaccess file is located in "/posts". Here's the contents:
RewriteEngine on
RewriteBase /
RewriteRule ^.*\.html$ ?url=/posts/2014/1215A.html [QSA]
The incoming request is for "/posts/2014/1214A.html". I want that request to be rewritten so as to be for, "/?url=/posts/2014/1215A.html". It appears that the regular expression is matched. The problem seems to be with the substitution. I've actually had the whole thing working; but, I must have somehow messed something up. Can anyone please tell me how to fix this? Thanks.
... doug
This should work :
RewriteEngine on
RewriteBase /posts/
RewriteCond %{REQUEST_URI} !^/posts/index
RewriteRule ^.*\.html$ ?url=/posts/2014/1215A.html [QSA]
I have the following entry in my .htaccess file:
RewriteRule ^blogs$ ?name=data&case=gview&group_id=31%1 [L]
What I do is, I redirect blogs to ?name=data&case=gview&group_id=31
Now what happens is, all my urls are now blogs?id=1 etc, but I need them to stay just ?id=1
How can I remove the blogs from rest of the urls?
This what I came up with, but it doesn't work:
RewriteRule ^blogs?(.*)$ /$1 [L]
EDIT I might be explaining it wrong. I need to change the actual url display of the links. Is that actually possible?
Not sure... but is that what you're looking for ?
RewriteRule ^/?$ /blogs [L,QSA]
What's wrong with just adding a R to your original rule?
RewriteRule ^blogs$ ?name=data&case=gview&group_id=31%1 [L,R=301]
Ok, the answer is pretty much: It can't be done. I just went over my code, added / before main urls and all is working as intended.
Thank you both for suggestions.
I've created a ReWriteRule, which I think points to claim.php?claimlisting=$#
The rule is written as follows :
# Claim
RewriteRule ^listing/claim/([a-zA-Z0-9-]+).(.html|htm)$ claim.php?claimlisting=$1 [L]
An example link is : /listing/claim/anne-morrison--hypnotherapy-cognitive-behaviour-therapists
I would like my MOD_REWRITE to point to the ROOT dir and claim.php?claimlisting=$ID_HERE
I've put the file up, But it doesnt seem to be affecting the site at all? Is what I've done correct and what else would be a factor preventing it from functioning correctly?
Thanks
# Claim
RewriteEngine On
RewriteRule ^listing/claim/([a-zA-Z0-9\-]+).(html|htm)$ /claim.php?claimlisting=$1 [L]
And you are missing .html at the end of link
You have an extra period.
RewriteRule ^listing/claim/([a-zA-Z0-9-]+)\.(html|htm)$ claim.php?claimlisting=$1 [L]
I removed the one in the second set of parenthesis, and escaped the first one. Try that.
I am trying to rewrite the URL using the mod_rewrite apache module.
I am trying to use it as below :
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^wants/testing.htm wants.php?wantid=$1 [L]
I have created a .htaccess file in the directory from where the files are accessed.
The mod_rewrite is also enabled.
With all these done, i still haven't been able to get it working.
Can someone please help me with this? Please let me know if i am missing something
Thanks in Advance,
Gnanesh
As per OP's comment:
The URL shows
mydomain.com/wants.php?wantid=123. I
need to make it look like
mydomain.com/wants/123
This should work for your case:
RewriteEngine on
RewriteBase /
RewriteRule ^wants/([0-9]+)$ /wants.php?wantid=$1 [L]
It will allow you to use http://yoursite.com/wants/123 and will silently rewrite it to wants.php?wantid=123
I think a leading slash (or rather the lack thereof) might be yoru problem:
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^wants/testing.htm /wants.php?wantid=$1 [L]
Otherwise Apache might be looking for the PHP file in /wants/wants.php as it'll be treating it as a relative URL.
Hmm, so I gave it some thought and I guess you could do something like this ( only changed the regexp according to your comment, if I understood correctly ):
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^wants/\d+$ /wants.php?wantid=$1 [L]
But I guess you could also leave out the $1 reference, and still be able to access the id in your wants.php. So
RewriteRule ^wants/\d+$ /wants.php [L]
should work too, and you can then use something like
<?php
$request = split('/', $_SERVER["REQUEST_URI"])[1];
?>
in your wants.php where the last element of the array would be your id ( or anything else you ever decide to rewrite and send to the script ).
If you want to use the rule in the .htaccess file in your wants directory, you have to strip the contextual wants/ from the start of the pattern. So just:
RewriteEngine on
RewriteRule ^([0-9]+)$ /wants.php?wantid=$1 [L]
Otherwise, if you want to use the rule in the .htaccess file in your root directory:
RewriteEngine on
RewriteRule ^wants/([0-9]+)$ wants.php?wantid=$1 [L]