MOD Rewrite - SEO Links

Status
Not open for further replies.

Zero

Active Member
639
2008
58
0
The script i use is costume and it is not WordPress or anything developed by a major company.

My goal:

domain.com/tos.php TO domain.com/tos/
domain.com/contact.php TO domain.com/contact/

The above would be pages my by me.

domain.com/search.php?search=wjunction&search_button=Search
TO
domain.com/torrent/wjunction/

The why my site works is as fallows:

1. Index.php has just a search box.
2. Once they have clicked search it displays all the results.

What does my .htaccess look like?

PHP:
Options +FollowSymLinks
 
RewriteEngine On
RewriteRule torrent/([^/]+)/?$ search.php?search=$1 [NC]     

ErrorDocument 404 http://domain.com

Please let me know how all this could be accomplish to work. Thank you for reading this.
 
5 comments
Modify your .htaccess to this:
PHP:
Options +FollowSymLinks
 
RewriteEngine On
RewriteRule ^tos/?$ tos.php [L]
RewriteRule ^contact/?$ contact.php [L]
RewriteRule ^torrent/([^/]+)/?$ search.php?search=$1 [L]     

ErrorDocument 404 http://domain.com

Your url's should be respectively available at these:
- domain.com/tos/
- domain.com/contact/
- torrent/wjunction/
 
I modified your code and it works the way i want now. But when they click search it doesnt function.

Examples:

torrents.ws - The main page.
torrents.ws/adobe.html - Loads properly - But it does not work when i click search.
torrents.ws/search.php?search=adobe&search_button=Search - How its currently searching.

How come i changed the .htaccess to:

PHP:
Options +FollowSymLinks
 
RewriteEngine On
RewriteRule ^([^-]*)\.html$ /search.php?search=$1&search_button=Search    

ErrorDocument 404 http://torrents.ws

Shouldn't it redirect by its self?
 
The script i use is costume and it is not WordPress or anything developed by a major company.

My goal:

domain.com/tos.php TO domain.com/tos/
domain.com/contact.php TO domain.com/contact/

The above would be pages my by me.

domain.com/search.php?search=wjunction&search_button=Search
TO
domain.com/torrent/wjunction/

The why my site works is as fallows:

1. Index.php has just a search box.
2. Once they have clicked search it displays all the results.

What does my .htaccess look like?

PHP:
Options +FollowSymLinks
 
RewriteEngine On
RewriteRule torrent/([^/]+)/?$ search.php?search=$1 [NC]     

ErrorDocument 404 http://domain.com

Please let me know how all this could be accomplish to work. Thank you for reading this.

I just wanted to point out, that while this DOES indeed work, it's always best to use Apache to handle these types of things, instead of mod_rewrite. Simply because it's faster under heavy traffic:

Code:
<VirtualHost *:80>
    ServerName domain.com
    ErrorLog /etc/httpd/logs/error_log
    <Directory /var/www/>
        RewriteRule ^tos/?$ tos.php [L]
        RewriteRule ^contact/?$ contact.php [L]
        RewriteRule ^torrent/([^/]+)/?$ search.php?search=$1 [L]  
    </Directory>
</VirtualHost>
 
Status
Not open for further replies.
Back
Top