I would like to redirect all paths like this:
myurl.com/worldwide/en
myurl.com/worldwide/pt
myurl.com/worldwide/de
to:
myurl.com/worldwide/index.php?lang=en
myurl.com/worldwide/index.php?lang=pt
myurl.com/worldwide/index.php?lang=de
Just to be clear a dynamic redirection of the pathname after /worldwide
Actually ideally I would like to keep the original url (e.g. myurl.com/worldwide/de) but load the same php file with the language directory as a param but not sure if this is possible?
Thanks
Use this code
RewriteEngine On
RewriteBase /worldwide/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?lang=$1 [L,QSA]
Please let me know if this helps you
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php !-f
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]
Related
Is it possible to using htaccess?
I want to keep my original url "menu", but also use /en/menu/ for it.
Here is my code so far (sorry I am terrible at htaccess):
RewriteEngine On
RewriteBase /server/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/menu/ [NC]
RewriteRule ^([^/]+)/([^/]+)en/menu/ [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /menu/ [L,QSA]
I'm trying to remove the proxy.php file and the parameter passed to it. This is what it looks like currently.
http://localhost/stuff/proxy.php?parameter=folder01/some.file
This is the way I would like it to look.
http://localhost/stuff/folder01/some.file
For my htaccess file, I have tried the following but they do not work.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /proxy.php?parameter=$1 [L]
And this
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /proxy.php?parameter=$1 [L,QSA]
Any ideas?
Try it in root dir or put this in stuff directory and remove RewriteBase line.
RewriteEngine on
RewriteBase /stuff/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ proxy.php?parameter=$1 [L]
I want to change page url with .htaccess my url is 'page.com/web/' and I want to have just page.com. Could you give me htacces code. for example
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /?$1 [L]
Try this :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ web/$1 [NC,L]
I would like to redirect link http://example.com/asdasdas/edit to http://example.com/asdasdas/index.php/edit using htaccess. I did this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} edit
RewriteRule ^ %{REQUEST_URI}/index.php [L,R=301]
but it's a loop and doesn't works well. Any ideas?
You can use this rule in /asdasdas/.htaccess:
RewriteEngine On
RewriteBase /asdasdas/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+) index.php/$ [L]
This will support URL of http://example.com/asdasdas/edit
Sorry if the title of the question is not clear, please read below for details;
I have this .htaccess:
Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?user=$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/home/.*$ index.php [QSA]
One of its functions is to redirect the url from this example:
www.example.com/user.php?user=david
to be:
www.example.com/david
Now, I have a file friends.php which function is to show friends of a particular user.
So the link that I wanted is like this:
www.example.com/david/friends
How can I achieve this?
You have to basically do the same as you did for user. In fact, the rule does not even conflict, because the user rule cannot contain a / character.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/friends$ friends.php?user=$1 [L]