I will try to be as clear as possible:
the htaccess file is located in
http://localhost:8080/trevision/.htaccess
below is whats included in htacesss
RewriteEngine On
RewriteRule ^search/$ /searchPage.php
essentially what this is trying to do redefine the default page on the search folder from index to searchPage.php
the searchPage is found in
http://localhost:8080/trevision/search/searchPage.php
I have already checked httpd.conf and its set to AllowOverride All everwhere
Any help would be appreciated.
For any clarification, let me know.
Try changing your rule's target to:
RewriteEngine On
RewriteRule ^search/$ search/searchPage.php [L]
Since the htaccess file is in /trevision/, that's where all relative paths will start from. When someone goes to /trevision/search/ the rule will match and get rewritten to /trevision/search/searchPage.php.
Alternatively, you can try adding in the htaccess file in the search folder:
DirectoryIndex searchPage.php
Related
I'm trying to use my .htaccess file but I still can't figure it out what am I doing wrong.
I only want my domain to be yescpol.com.br, and it always comes like this
My .htaccess is inside the folder "porcelanato" and it has this code:
RewriteEngine on
RewriteBase /porcelanato/
I only want my index.php to turn into yescpol.com.br
What am I doing wrong?
The easiest thing to do would be to change the DocumentRoot in the domain configuration or move your files out of that folder and into the root.
If you want to stick with the rewrite method, you will need to add a rule like this.
RewriteEngine On
RewriteRule ^$ /porcelanato [L]
Add this line to the top of your .htaccess file:
DirectoryIndex index.php
Though if this property is set properly on your apache service in httpd.conf (or whatever is serving your pages) this won't have to be added to your .htaccess file.
In my site I use "show.php?cat=1" type URLs. I want to change for SEO optimization this link types.
I have tried before but I can't understand how to do that.
# Root Host
-- Project Folder
--- index.php
--- show.php
--- css/js/ and other folders
My first purpose is change my links
show.php?cat=1 to show/1/
my code is
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/show/(.*)$ show.php?cat=$1 [QSA,L]
But it doesn't work. I have a GET error. What's wrong?
And my css files gone to /show/css URL
I'am very angry, my css files gone but Get function doesn't work.
Thanks for help.
Edit: If I change show code to 'test' like that, page becomes 404. Why?
Note: I'am using WAMP Server 3, Apache Rewrite_module is working.
RewriteRule ^/test/(.*)$ show.php?cat=$1 [QSA,L]
"The requested URL /project1/test/1 was not found on this server."
Use:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^show/(.*)$ show.php?cat=$1 [QSA,L]
Without first / in htaccess RewriteRule pattern
My friend recently told me that I was able to do something like
http://example.com/about/
without having to create a directory and place a index.html inside of it, like this.
http://example.com/about/index.html
How in the world do you do this? I didn't know it was even possible to do unless you created a directory and placed a index.html inside of it, anyway thanks. :)
If you use Apache as WEB server, use .htaccess for you site root directory.
Write following rule here:
DirectoryIndex index.html
Also you can use more than one file here:
DirectoryIndex index.php index.html
In this case first found will be used.
If you don't want to use .htaccess, you can setup same in Apache config file (httpd.conf):
< Directory /foo>
DirectoryIndex index.html
DirectoryIndex index.php
< /Directory>
Here /foo - root directory of your site
Servers like Nginx can allow you to rewrite URLs, so you can place your file wherever you want.
If you use Apache web server then create a file named .htaccess
and write code like below
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?load=$1 [PT,L]
If this code when you type a url like www.example.com/about its doing to open your aboutController
Write aabout in this url http://salopek.eu/content/28/create-a-simple-php-mvc-framework
If you does not use Apache or you want simple solution then then you can just create a folder named about and create a simple index.html or index.php file. Then when you type www.example.com/about
it opens your about\index.html or index.php file
I hope it helps
I have to change url with .htaccess
.htaccess is stored in link folder.
My .htaccess file is
Options -Multiviews
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([1-9a-z]*)$ index.php\?u=$1 [L]
when i open this
'http://example.com/link/index.php?u=3ujkzf'
url it works.
But when I open
'http://example.com/link/3ujkzf' short link
I got default godaddy hosting error page.
Please Help..
Thank you for Reading..
If your project is located in the link folder, you need to include that:
RewriteRule ^link/([1-9a-z]*)$ /link/index.php?u=$1 [L]
By the way, you don't need to escape the question mark in the second part of the rewrite rule
try adding RewriteBase /
just below RewiteEngine On
I have a website, say http://mysite.com. I would like to put index.php in a subdirectory, public_html/mysubdir/index.php. I would like public_html/mysubdir/index.php to get executed when the user goes to http://mysite.com. And I would like the url to continue to read http://mysite.com. Is this possible?
If your webserver is Apache you could use URL rewriting with mod_rewrite.
Another option is to create an index.php in the root directory and include index.php in the sub directory.
Rewrite rules may be overkill for this depending on what you want. For just your main index page, this will work...
Simply adding this one line to your .htaccess file:
DirectoryIndex mysubdir/index.php
It will display the page located at mysubdir/index.php while simply showing http://mysite.com in the URL.
I use this method myself. While all of my pages are located in the same subdirectory, the home page is displayed with my domain name by itself (http://www.mysite.com). All other pages show the full URL.
If you also have index pages within deeper subdirectories and want those to come up by default within the subdirectory.
Example:
If you want this page: http://mysite.com/mysubdir/anothersub/index.php
to come up with this URL: http://mysite.com/mysubdir/anothersub/
Then modify the line with another index.php like this...
DirectoryIndex mysubdir/index.php index.php
What this does is tell the server to look for files with those names in that same order. If it can't find the first, it tries the second, and so on.
When you're inside your root at / it finds and then displays mysubdir/index.php.
When you're inside another subdirectory like /mysubdir/anothersub/, it can't find anything named mysubdir/index.php so it goes to the next item and displays index.php
You could use a .htaccess file and define Rewrite rules.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Make sure that mod_rewrite is enabled and then place .htaccess file in your root directory with something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ your_subdir/index.php/$1 [L]
</IfModule>