I am very new to URL rewriting using .htaccess and I would like to redirect anyone entering the domain below
http://domain.tld/admin
to be redirected to
http://domain.tld/index.php?section=admin
but without including the full address. This is the code I am using but it doesnt seem to work
Options -Indexes
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^admin /index.php?section=admin
</IfModule>
Where Im I going wrong?
Thanks
You can use this more correct regex rule with L flag:
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^admin/? index.php?section=admin [L,QSA,NC]
Related
When i click on a link it should redirect to
for ex; www.domain.com/demo/item.php?item=abc&id=3
but in url it should show as www.domain.com/demo/abc/3
im Using
<IfModule mod_rewrite.c>
Options +SymlinksIfOwnerMatches
RewriteEngine on
RewriteRule ^demo/(.+) demo/item.php?item=$1&id=$2 [NC,L]
Please help
You can try with this one, it will not redirect your URL but if you execute your URL (www.domain.com/demo/abc/3) it will be work.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]
You could try like this after adding the rewritebase directive
RewriteEngine on
RewriteBase /
RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]
In my application we have write root directory name(gaming) statically in coding on some pages which are showing as link in GUI. Now whenever I am trying to click on such URLs its redirect me on url1 which is not accessible for me. So is there any possible ways in which I can access url1 without remove such statically name throughout application?
URL 1 :
http://abc:8089/gaming/app/test/unique_testing.php
URL 2 :
http://abc:8089/app/test/unique_testing.php
I have tried some htaccess overwrite rules but it's not working for me.
My current htaccess looks like below :
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^gaming(/.*|)$ /$1 [L,NC]
Structure :
/var/www/html/gaming/app/test/unique_testing.php
/var/www/html/gaming/.htaccess
Inside root /gaming./.htaccess you can use this rule:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^app(?:/.*)?$ /$0 [L,NC]
Please use this rules in your .htaccess
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^app/(.*)$ /$1 [L,NC,R]
I want to modify URL with a check.
If there exists experiment as second folder, then do this
{site}.com/dashboard/experiment/closed/.../
to
{site}.com/experiment/closed/.../
If no experiment found in path, then don't do anything. For eg
{site}.com/dashboard/ex-view/closed/.../
How do I achive this using htaccess. I'm using Laravel 5.1.
This is what I tried but it doesn't meet the second condition.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^experiment/(.*)$ /$1 [L,NC,R]
You can try this rule in the .htaccess in the root. The should only affect URL with experiment as the second folder.
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^.+/experiment/(.*)$ /experiment/$1 [L,NC,R]
Can you help me out with my problem about .htaccess redirecting the display images in other server..
i got this in my .htaccess
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ http://www.newurl.com/folder/folder/i/m/img_4fa231e793149_s.png
[NC,L]
this htaccess only redirects only one images which is img_4fa231e793149_s.png
i would like to do is to retrieve all the images which is here ->http://www.newurl.com/folder/folder/i/m/...
any help is appreciated thanks a lot....
Use your captured group $1:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /magento/media/catalog/product/i/m/
RewriteRule ^(img_[^.]+\.(?:jpg|png|jpeg|gif))$ http://www.tokopals.com/Dan/Magento_images/i/m/$1 [NC,L,R]
I have been looking all over the place to find some code to work with my godaddy URL Rewriting, but no luck.
I am trying to make my website with Friendly URLS with .htaccess e.g. domain.com/company/buy/items.php?fatherID=23 ==> into ==> domain.com/23 I tried almost all codes and the best i got to is removing the .php
Sample Code:
Options +FollowSymLinks -MultiViews
Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]
Does anyone have any idea with some simple code? I am on godaddys shared Linux server.
I tried to redurect 404 error codes with:
ErrorDocument 404 /domain.com/home/404error.php
but this also did not work.
Is there something I am missing?
Try this , it should be work
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^([0-9]+)$ company/items.php?fatherID=$1 [L]
</IfModule>
Godaddy is a special case. It will work surely.
DirectoryIndex index.php
AddDefaultCharset utf-8
RewriteEngine on
Options +FollowSymlinks -MultiViews -Indexes
RewriteBase /
RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]