I have a url structure that looks like this:
http://www.blahblah.com/community/i/pagename
However, I want to remove the ugly /i/ part. Is this possible with Modrewrite?
Yes, it's possible:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(\w+)/(\w+)$ $1/i/$2 [QSA]
</IfModule>
Related
I've go a .htaccess file on my server with this code:
RewriteEngine on
RewriteRule ^([a-z0-9-]+)? index.php?i=$1 [L]
When I run this I've got something like this:
http://example.com/index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.phpi=index.php?i=XYZ
How to get link look like this:
http://example.com/index.php?i=XYZ
from link look like this
http://example.oom/XYZ/ABC/123
I only need first XYZ to index.php?i=XYZ
Working code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^/.]+)?$ index.php?i=$1 [L]
</IfModule>
I have a URL:
www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space
I want to stay on the same page above but simply display the URL in the address bar like this:
www.example.com/property-listings/united-states/colorado/denver/office-space
How do I accomplish this using htaccess and rewrite rules?
If I understood right, try writing a rule like this one:
RewriteEngine on
RewriteRule property-listings/united-states/colorado/denver/office-space http://www.example.com/property-listings/united-states/colorado/denver/denver-co-office-space [L]
OK. You didn't supply a pattern or mentioned there was any, so I have to guess the pattern is up to /denver/ subdirectory. Try this:
RewriteEngine on
RewriteRule ^(property-listings/united-states/colorado/denver/)(office-space)/?$ $1denver-co-$2 [L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^(property-listings/united-states/colorado)/(denver)/(office-space)/?$ $1/$2/$2-co-$3 [L,NC]
i want to rewrite the url http://www.host.com/de/rss to the file http://www.host.com/index.php?type=9000001&L=1
My rewrite rule look like this:
RewriteRule ^de/rss(.*) index.php?type=9000001&L=1
But this does not work. If i delete de/ it works with the corresponding url.
I tried to look for similar questions here on stackoverflow, but that didnĀ“t help.
Use this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^de/rss/?$ index.php?type=9000001&L=1 [L,QSA,NC]
And if doesn't work then please post your full .htaccess in your question.
Maybe you should try this:
RewriteRule ^/de/rss.*$ /index.php?type=9000001&L=1
Ok I have a script in the folder 'intake'. The index.php file auto creates a list of urls. Those urls are in the format:
/intake/4/Westrop
I have an .htaccess file in the intake folder. I want it to redirect the url to a FILE.
The above example would then become /intake/redirect.php?id=4&name=Westrop
Here's what I have so far:
DirectoryIndex index.php
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/(.*)$ /intake/redirect.php?id=$1&name=$2 [L]
</IfModule>
But for some reason if I type /intake or /intake/index.php I get a 404 error. According to firebug its trying to take "intake" and turn it into "intake.php"
Any ideas?
Place the following code in .htaccess file in website root folder:
RewriteEngine On
RewriteRule ^intake/(\d+)/([a-z0-9\-_]+)$ /intake/redirect.php?id=$1&name=$2 [NC,QSA,L]
P.S.
Do not use this sort of pattern -- ^(.*)/(.*)$ -- in your case for longer URLs it will work not as you would expect. It will match your URL .. but in a wrong way.
Start your .htaccess with this option:
Options +All -MultiViews -Indexes
I want my js-files in the folder scripts to be redirected to a php which handels the caching. So the .htaccess looks like this:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /eval/widget/scripts
RewriteRule ^(.*)\.js$ func.php?src=$1
The filename (without extension) should be passed to the php-file, but instead the src parameter is 'scripts/JAVASCRIPT_FILENAME'. What's wrong with this? Seems like RewriteBase doesn't set it correctly...
Change your rewrite rule to
RewriteRule ^.*?/(.*)\.js$ func.php?src=$1
You understanding of RewriteBase is incorrect.