Ok, So I am very noob with htaccess. Basically, I want my site
http://mydomain.com/game.html
to go to
http://mydomain.com/index.php?page=game
I don't have a current .htaccess because almost all I've tried, have failed.
Does anyone have a working one to that?
Try adding this to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)\.html$ /index.php?page=$1 [L,QSA]
This internally rewrites a request for /anything.html to /index.php?page=anything. You'll have to make sure all of your links look like http://mydomain.com/anything.html though, because it doesn't do anything about what's shown in the browser's URL address bar.
Related
I need to hide a folder from a url.
An example:
If I enter www.mysite.com/Jango
I need you to read the directory: www.mysite.com/users/Jango
but do not want to see /users
I just want to see this in the address bar:
www.mysite.com/Jango
This .htaccess in / should do:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^users/
RewriteRule ^(.*)$ users/$1 [L]
This treats any requset not starting with users/ as if it did.
Update:
If you want the rule to apply for only /Jango --> /users/Jango, this would be an appropriate .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^users/Jango
RewriteRule ^Jango/(.*)$ users/Jango/$1 [L]
(The [L]-flag stops rewriting afther this rule, preventing possible circle-reactions etc)
What I mean by last name in the url, like index.html for example the url link on my website homepage. the result is like this
https://hijaben.insomnia247.nl/index.html
I want to remove or delete the last name of the url (index.html)
I tried using the .htaccess file but it didn't work at all. Is it possible the script is wrong or the VPS doesn't support or what? the solution ..?
File .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
</IfModule>
https://www.digitalocean.com/community/tutorials/how-to-rewrite-urls-with-mod_rewrite-for-apache-on-ubuntu-16-04
Please check this out im sure it can help you with your problem sir.
https://www.linode.com/docs/web-servers/apache/how-to-set-up-htaccess-on-apache/
Don't overcomplicate things with unnecessary mod_rewrite. Just use DirectoryIndex index.html.
I was wondering how this site https://www.jrsa.com.ar/ works with friendly URLS and languaje selector.
For example, if you put https://www.jrsa.com.ar/es https://www.jrsa.com.ar/es/es is the same result, the same page. In the browser if you write https://www.jrsa.com.ar/servicios is the same if you write http://www.jrsa.com.ar/es/ex/servicios.
In the browser if you type www.jrsa.com.ar/folder/folder/folder/servicios is the same as www.jrsa.com.ar/servicios. I canĀ“t understand how you can add folders and getting the same page.
Can some help me to find to achieve this? I only have this htaccess
# Activar RewriteEngine
AddDefaultCharset UTF-8
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.html [NC,L]
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Mi test URL is: http://clients.devilleartstudios.com/jrsa
Thank You
I suspect their content is stored in a CMS database that supports localized content. It is not feasible to do this with a manually-managed static website because you'll need to recreate common HTML structure (like navigation, global content, etc) in every page. If you really want to accomplish this with a static website then consider using a system like Jekyll: https://jekyllrb.com/
My aim is:
domain.com/folder
rewrite ->
domain.com
this shall concern ALL links inside that site.
I mean on the site are links like:
domain.com/folder/forum.html
domain.com/folder/community.html
etc.
This is my aim:
domain.com/forum.html
domain.com/community.html
etc.
and its very important that the "folder" is never in the url in the adressbar visible.
I tried already many codes but I couldnt really solve this problem.
My best try was with this code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)folder
RewriteRule ^(.*)$ folder/$1 [L]
If I enter
domain.com
I get the content of
domain.com/folder
displayed, what is correct ("folder" is not in the url shown). But when i click on some links of the site like: domain.com/folder/community.html then I can see again "folder" in the url, but I want that it becomes ALWAYS removed.
here is my site:
thewedgiecommunity.x10.mx/wedgiecommunity/
My aim is to remove the "wedgiecommunity" (=folder)
This link is working
thewedgiecommunity.x10.mx/
But when you click on Community (
thewedgiecommunity.x10.mx/wedgiecommunity/community.html
) then i get again "wedgiecommunity" in the URL.
Would be awesome when someone could help me
You can use this code:
Goes in DOCUMENT_ROOT/wedgiecommunity/.htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+wedgiecommunity([^\s]*) [NC]
RewriteRule ^ %1 [R=301,L]
Goes in DOCUMENT_ROOT/.htaccess:
RewriteEngine On
RewriteRule !^/?wedgiecommunity wedgiecommunity%{REQUEST_URI} [L,NC]
You can use this rule to "remove" the folder from the URL when it is accessed directly via the browser:
RewriteCond %{THE_REQUEST} \ /wedgiecommunity/
RewriteRule ^wedgiecommunity/(.*)$ /$1 [L,R=301]
Then your other rule will handle the rest.
I use Dokuwiki for my website. I have a quick question about htaccess rewrite rules. I have the following configuration. The suggestions come from the Dokuwiki help.
Options -Indexes -MultiViews +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^lib/exe/xmlrpc.php$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ doku.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) doku.php?id=$1 [QSA,L]
RewriteRule ^index.php$ doku.php
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
I admit that I don't understand all of what's going on. The important thing is that I want
http://mydomain.com
to be changed to
http://www.mydomain.com
and also any subdomains. Also, I want to get rid of the ugly Dokuwiki syntax, which attaches things like doku.php? to the end of links.
Currently, the transformation with this .htaccess file is:
[Good] www.mydomain.com --> www.mydomain.com
[Good] www.mydomain.com/mypage --> www.mydomain.com/mypage
[Bad] mydomain.com --> www.mydomain.com/doku.php
[Bad] mydomain.com/mypage --> www.mydomain.com/doku.php?id=mypage
so you see, it seems to work properly if I attach www in front of things, but when I don't, then the re-write rule attaches the proper www, but now the ugly wiki syntax also accompanies the site name (doku.php and id= parts).
Where did I go wrong in the htaccess configuration?
TSGM, that looks fine except that you have the rewrite from mydomain.com to www.mydomain.com as the last two lines. Move the last two line up so that they are just after RewriteEngine on and that should fix it.
The reason being that (sometimes) a redirect was triggered to create the 'clean urls' and when this happened the rewrite to www never gets executed.
By moving the two lines up, you are forcing the www rewrite to happen first before the doku rewrite kicks in.