.htaccess rule to skip folder name from entire urls - .htaccess

My project name is funfeesa and all client side pages are contains in "client" folder. But I want to access then without to write client folder in the url.
just like below:
localhost/funfeesa/index.php
I have tried many rules in .htaccess file but nothing is working fine.
can anyone help me?

#prevent directory listing
Options -Indexes
IndexIgnore */*
#follow symbolic links
Options FollowSymlinks
RewriteEngine on
RewriteRule ^funfeesa/index.php(.+)?$ funfeesa/client/index.php/$1
Try to access your .htaccess file as above
Still if it doesn't work try by removing index.php from above rules but I think It should work :)

Related

Options +Indexes of .htaccess not working

I have a website running on a server. It's just an index.html with a hello world text. Also, I have a folder named /vpn which contains various txt files and an index.html file.
If I try to access the URL domain/vpn, it shows me the content of index.html.
I just need to show the files inside the folder vpn when the user tries to access domain/vpn.
I created an .htaccess file with the next content in the root:
RewriteEngine on
<If "%{REQUEST_URI} == '/vpn/'">
DirectoryIndex disabled
Options +Indexes
</If>
When I try to access to vpn, it shows me a 404 error, the requested URL was not found on this server.
.htaccess is applying the DirectoryIndex rule (If a delete it, it shows me index.html content again), but not the Options +Indexes one.
I tried the same example in localhost (with XAMPP) and it's working fine.
What can be the problem?
PD: This is the content of apache2.conf file:
When I try to acces to vpn, it shows me a 404 error, the requested URL was not found on this server.
If you are getting a "404 Not Found" then it would imply that mod_autoindex is not actually installed on your server (consequently Options +Indexes has no effect - although it would seem from your server config that Indexes is perhaps already enabled).
mod_autoindex is the module responsible for generating the directory listings.
I created an .htaccess file with the next content in the root:
Personally, I would create an additional .htaccess file in the /vpn directory instead:
DirectoryIndex disabled
Options +Indexes
And disable Indexes (and set DirectoryIndex) in the root .htaccess file.
NB: RewriteEngine has no place here, unless you are overriding a parent config.
If I try to access the url "domain/vpn"
Note that you should be requesting domain/vpn/ (with a trailing slash). If you omit the trailing slash then mod_dir issues a 301 redirect to append it.

rewrite index.php?p=page to page

My urls currently look like this: http://www.morrisononline.com/index.php?p=contact
I would like to rewrite them to http://www.morrisononline.com/contact
The content for (in this case) contact comes from the directory /pages/ (www.morrisononline.com/pages/contact.php)
I have tried the following in the .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9-_]+)/?$ index.php?p=$1 [NC,L]
I have also tried other combinations too (I'm not very good at this and trying lots of suggestions from other forum posts etc) but nothing has any effect. No error messages and no rewrites either. Did I do it wrong or could there be another command before that, that overrides this?
Do I have to refresh some cache or restart the server for this to work?
Make sure you have AllowOverride All or at least AllowOverride FileInfo in your site's config for the site's document root. And make sure the htaccess file is in the document root, is readable by everyone. If it's still not working, make sure that you've got AccessFileName set to .htaccess.

URL Rewriting not working?

im new here.
Im trying to rewrite some urls on my site only for some reason no matter what I try I cannot get them to work!
My directory on my server has the following...
index.php
user-profile.php
.htaccess
On my index.php there is a number of users that all have a view more details button that links through to user-profiles and posts an ID using GET method as such...
http://mysite.com/user-profile.php?userID=2&firstName=Martin&lastName=FAM
However Id like to format them as so...
http://mysite.com/people/2/Martin/FAM
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /user-profile.php?userID=$1&firstName=$2&lastName=$3 [L]
Can anybody give me some reason as too why this isnt working?
The regex should be
^people/([^/]*)/([^/]*)/([^/]*)$
You need to make sure you have this option set in your document root directory in Apache's httpd.conf file:
AllowOverride All

Replace all requested images with test.jpg in htaccess

I'm trying to replace all requested images with a test image inside my .htaccess file
(running Apache2.2/Coldfusion8) like so:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteRule \.(?:jpe?g|?:JPE?G|gif|png)$ test.jpg
</IfModule>
The test.jpg is in the same folder as my .htaccess file, which I have cleared everything from except the above snippet.
Problem is, still nothing happens.
Question:
Can someone tell me what I'm doing wrong?
EDIT:
Must be something in the httpd.conf settings I guess. I have set:
AllowOverride All
in the document root directory, but still doesn't do anything.
Thanks for help!
try adding some random text to the htaccess and see if you get a 500 error message. If not, htaccess is not enabled.

Allowing/Disallowing directory listings with .htaccess

I have a wordpress site running, and currently anyone can view the uploads directory by visiting
http://site.com/wp-content/uploads
I want to stop this directory from being viewed in a browser but I want a subfolder to be viewable (eg. http://site.com/wp-content/uploads/PublicUploads). I have tried setting
IndexIgnore *
in the uploads folder, but I cannot work out how to set the sub folder back to visible.
Any help would be appreciated
Most people use
Options -indexes
To make a subdirectory visible again, you'll need to put a .htaccess file inside that subdir, with Options +indexes inside it.
Using mod_rewrite you can block direct access to wp-content/uploads directory like this:
RewriteRule ^wp-content/uploads/?$ - [F,NC]
Keep in mind that this will only block browsing of /wp-content/uploads contents but will allow /wp-content/uploads/PublicUploads or any /wp-content/uploads/foo.

Resources