I am trying to make a friendly url for my website but when i use it, it always uses the current folder as rewrite and not show images, css,...
RewriteEngine On
RewriteOptions inherit
Options +FollowSymlinks
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^number/([a-z0-9]+)/?$ /index.php?id=read&num=$1 [L,NC]
and i have result as mydomain.com/number/123456/
but my page not showing with theme because all link js,css,images,... change in to /number/123456/
example: mydomain.com/number/123456/css/style.css or mydomain.com/number/123456/images/logo.png
But all that in root folder is mydomain.com/css and mydomain.com/images ~~!
How can i use with that format and my page can show correctly :(
Any solutions?
Please help me!
Related
I want to put up a site for demo purposes in a subfolder on my server, where all links are using relative paths (i.e. starting with "/"). This defaults back to the root folder, the easiest way to solve this would probably be to set up a htaccess file. I just cant seem to get it right. Am I missing something here? I've tested and made sure mod_rewrite is enabled inside the folder.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /mydemo/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
You can place all your web scripts, php, html, css, image files in mydemo/ folder and have this .htaccess in site root:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!mydemo/)(.*)$ mydemo/$1 [L,NC]
So for two days I can not understand why this won't work...:
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^advice/([a-zA-Z]+)/([0-9]+)/$ advice.php?advice=$1&id=$2
Obviously .htaccess is allowed since I am not able to directory open folders, but why doesn't the link work?
Try turning off multiviews so the server doesn't try and search for that as a file. In addition add the conditions so that it knows it's not looking for a real file or directory it's trying to serve and make the trailing slash optional.
Options -Indexes +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^advice/([a-zA-Z]+)/([0-9]+)/?$ /advice.php?advice=$1&id=$2 [L]
Does your RewriteRule redirect to an existing file?
Try this, it works for me
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /test2/test.php
http://example.com/test2/.htaccess shows the location of the .htaccess file
http://example.com/test2/test.php is a direct link
http://example.com/test2/testX4XX opens the same test.php file using rewrite
i'm learning how to rewrite urls and im trying to do that in my ubuntu server. I managed myselft to activate the Allowoverride All and i have htacess working.
I want to change this url for example:
http://serverismai/myapi/public/rest/navigate.php
And i try to do it like this :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home(.*)$ myapi/public/rest/curso/navigate.php/$1 [L]
</IfModule>
I've tried various solutions but this was the closest i got. The url dosent change automatically but if i insert http://serverismai/myapi/public/rest/home i see a blank page with some of my website html written ( not even the html of the page i'm trying to rewite url).
I'm pretty new to this so i want to know if there is something wrong in the Rewrite Rule or if my error is somewhere else...
Thank you!
You can use this code in your /myapi/public/rest/.htaccess file:
RewriteEngine On
RewriteBase /myapi/public/rest/
RewriteRule ^home/?$ curso/navigate.php [L,NC]
I've been trying to create a page that can be accessed by passing a query string to check what version should be loaded. Instead of accessing the page by using www.domain.com?version=one I'd like to be able to use www.domain.com/one and the rule should turn /one into /version=one.
Is this possible?
Something like this should work.
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 /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /?version=$1 [L,QSA]
I would want an adress like this:
http://www.domain.com/some_page123/
to display the content of this page:
http://www.domain.com/script.php?var=some_page123
But i want the URL that appears in the browser to be www.domain.com/some_page123/
Is it possible to do that with htaccess even if the folder "some_page123" doesn't really exist ?
Also, i want to exclude the folder named "infos" from this rewriting. So if an user access the URL www.domain.com/infos/ then it will display the content of "infos" folder. I do NOT want to use script.php rewriting for the folder "infos"
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 /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (?!^infos/)^(.+?)/?$ /script.php?var=$1 [L,QSA,NC]
add .htacces in your root directory:
RewriteRule ^script.php - [L,NC]
RewriteRule ^infos/$ - [L,NC]
RewriteRule ^(.*)$ /script.php?var=$1
now I have tested it, it should be working.