htaccess url folder redirect - php

I am trying to change my url to try to stop it from showing the language folder in the url for example:
change from
www.site.com/en
change to
www.site.com
so I am looking to remove the
en
from the url but still accessing that directory. This is what I have so far but it does not seem to do the trick:
RewriteEngine on
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .+ en=$0 [L,QSA]
Thank you.

This should do it:
RewriteEngine on
RewriteBase /mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ en/$1 [L,QSA]

Related

.htaccess URL Rewrite not working (trying to send GET data with it)

I'm trying to rewrite a url that looks like http://example.com/View/(random_text) to take the user to http://example.com/View/site.php?site=(random_text)
This is what I am ussing so far:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^View/(.+)$ View/site.php?site=$1 [NC]
Any help is appreciated, thanks.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/View/(.+)$ /View/site.php?site=$2 [L,R=301]
If the "View" directory is in your webserver's root directory, then add just the single forward slash as above. Else add the path to the view directory like below:
RewriteRule ^(.*)/View/(.+)$ /path_to_view_directory/View/site.php?site=$2 [L,R=301]

Dynamic url change into seo friendly url

A very common problem, but couldn't fix the issue.
I want
http://website.de/page.php?module=helios
into
http://website.de/page/helios
I have tried lots of .htaccess code like this one, but still page sends to 404.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page.php?module=$1
Please provide some suggestions.
Try this rule in your site root .htaccess:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/([^/]+)/?$ page.php?module=$1 [L,NC,QSA]
Try...
RewriteRule ^page/([^/]*)/$ /page.php?module=$1 [L]
Use this use your base path
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/(.*)$ page.php?module=$1

How to load default index file with .htaccess for variable directory structure in url

Lets say my site structure is like this:
www.mywebsite.com/directory/$variabledirectoryname/$variableproductlink
As you can see in the middle i have 2 variables in the url, but the last is the poduct link. My index.php file stays in www.mywebsite.com/directory/$variabledirectoryname folder. How to load it?
I have this code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php [L]
But it doesnt work.. Thanks !
You can use this rule in /directory/.htaccess:
RewriteEngine On
RewriteBase /directory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/[^/]+/?$ $1/index.php [L]
Update:
You can use this rule in root .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(directory/[^/]+)/[^/]+/?$ $1/index.php [L]

htaccess is not redirecting

Well, i want the user to enter localhost/$value so it will redirect to localhost/pirsum/index.php?page=g&link=$value but its not working.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/([^/]+)/?$ [NC]
RewriteRule .* index.php?page=g&link=%1 [L]
I tried to enter localhost/ AND localhost/pirsum and both ended on 404 Not found site.
Now, thats the only part of my website that i need to use htaccess, so i dont want the whole site to redirect, just that part.
Use this rule:
RewriteEngine On
RewriteBase /pirsum/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?page=g&link=$1 [L,QSA]

Change URL name with mod rewrite on htaccess

I am having a tough time to understand how mod_rewrite works.
I have a url like this:
www.example.com/store/index.php?categ=headbands
And I want to make it look like this:
www.example.com/store/headbands
I am trying this, but not working:
RewriteEngine on
RewriteBase /store/
RewriteRule ^index/([^/\.]+)/?$ $1 [L]
And I confirmed the mod_rewrite is activated with a random example I found.
Any suggestions?
Thanks!
Try This one
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^/store/(.*)$ /store/index.php?categ=$1 [NC,L]
OR
Put the .htaccess file inside the "store" directory with following code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?categ=$1 [NC,L]

Categories