Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have my website directory like this:
application
assets
system
And under application I got this:
help
contact
I created a file inside each one called index.php so the URL can look something like this, but I have seen so many websites with an URL like this, I've seen this is made with .htaccess file, but the problem is that I don't know where should I put it and how to set it up.
Would be nice if you put some examples.
The apache site has tons of examples.
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
This isn't tested, but something like this should suffice.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/application/
RewriteRule ^(.*)$ /application/$1 [L,QSA]
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
For a project, I need to make every directory (server.com/dir1, server.com/dir2) look like there is the directory, even when there is not. I could say I need a directory wildcard. Say the content would be somewhere on the server, and gets included in the directories. Is there a way to achieve this with .htaccess?
Thanks!
Try something like this
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)/*$ ./yourActualScript.php?directory=$1
The regex part in brackets is your folder, the slash star is the rest of the url (if any), and the request will be sent to an actual script with GET var directory
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to prevent users to view the contents of all html files.
Example:
website.com/join/view_template.html (and it will display all the codes including the smarty)
I would like them to be redirected to 404 page if they do this.
I'm not sure if this is possible in htaccess.
You can use the following line in htaccess :
RedirectMatch 404 ^/.+\.html
This will return 404 not found error for all .html files.
Try it like this although I didn't try it for now,
RewriteEngine On
RewriteRule \.html - [R=404]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a hosted Apache based website. Currently, we create a new project folder on the site, and dump the flash based course up for review. Is there a way to make the content folder expire after a certain amount of time so that the content is no longer view-able?
Please let me know if you need any further clarification.
Yes, you can, using mod_rewrite module.
For example, to deny all requests since November 2014 you could use these rules:
RewriteCond %{TIME_YEAR} =2014
RewriteCond %{TIME_MON} >10
RewriteRule .* /deny.html
RewriteCond %{TIME_YEAR} >2014
RewriteRule .* /deny.html
To see all the available environment variables check the link below.
PS: you obviously need to provide some nice /deny.html page so that it was obvious for visitor what happened.
Or if you just need a standard 404/403 use the following rule:
RewriteRule .* - [R=404]
References:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a path of /posts/Bob/53c6acf8963e3/
Where posts relates to a file called post.php.
Bob is a username and 53c6acf8963e3 is a unique string.
so it should relate to something like post.php?username=bob&unique_string=53c6acf8963e3
But I don't want to use that as it doesn't look nice aha.
What htaccess rule could I use?
You can use this rules :
RewriteEngine on
RewriteRule ^([\w]+)/([\w]+)/([\w]+)/?$ $1.php?username=$2&unique_string=$3 [QSA,L]
See more on QSA flag here.
RewriteEngine on
RewriteRule ^([a-zA-Z]+)/([a-zA-Z]+)/([a-zA-Z0-9]+)/?$ $1.php?username=$2&unique_string=$3 [NC,L]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have URL that will be like that :
http://example.com/directory/index.php?q=anything
so that the PHP will load the test variable using $_GET['q'].
I wish to simplify this in my .htaccess to :
http://example.com/directory/anything.html
How would i go about doing this?
May be you could add something like this in .htaccess
RewriteEngine on
RewriteRule ([0-9A-Za-z-\+._]+)\.html$ ./index.php?q=$1
I have Myself resolve this issue ::
here's The .htaccess code
RewriteEngine On
RewriteRule ^directory/([^/]*)\.html$ /directory/index.php?q=$1 [L]