GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   htaccess rewrite remove file extension? (https://gfy.com/showthread.php?t=1040995)

acctman 10-07-2011 11:31 PM

htaccess rewrite remove file extension?
 
anyone have an example of how to write url file extension

specific rewrite...
http://www.site.com/members.html to http://www.site.com/main

and then remove all extension for all files ending in *.html
http://www.site.com/*.html to http://www.site.com/*

also this needs to work with and without www

my current htaccess
Code:

<IfModule mod_rewrite.c>
RewriteEngine On               
RewriteCond %{HTTP_HOST} ^(ssss\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?ssss\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.ssss\.com$ [NC]
RewriteRule ^(.*)$ http://www.ssss.com/view/%2.html [R=301,L]
RewriteCond %{REQUEST_URI} !^files/
RewriteCond %{REQUEST_FILENAME}  !-d
RewriteCond %{REQUEST_FILENAME}  !-f
RewriteRule ^(.*) index.php [L]
</IfModule>


fris 10-08-2011 07:09 AM

Quote:

Originally Posted by acctman (Post 18477074)
anyone have an example of how to write url file extension

specific rewrite...
http://www.site.com/members.html to http://www.site.com/main

and then remove all extension for all files ending in *.html
http://www.site.com/*.html to http://www.site.com/*

also this needs to work with and without www

my current htaccess
Code:

<IfModule mod_rewrite.c>
RewriteEngine On               
RewriteCond %{HTTP_HOST} ^(ssss\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?ssss\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.ssss\.com$ [NC]
RewriteRule ^(.*)$ http://www.ssss.com/view/%2.html [R=301,L]
RewriteCond %{REQUEST_URI} !^files/
RewriteCond %{REQUEST_FILENAME}  !-d
RewriteCond %{REQUEST_FILENAME}  !-f
RewriteRule ^(.*) index.php [L]
</IfModule>


need more descriptive what you want.

but here is the basis


Quote:

Options +FollowSymLinks
RewriteEngine On

# which do you want?

# make /members.html use /main
RewriteRule ^members.html /main [NC]

# make /main use /members.html
RewriteRule ^main /members.html [NC]

# alias /filename.html to /filename (dont know if you want to redirect the .html to the non or just make it work without

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
hope this helps you out somewhat.

acctman 10-08-2011 01:44 PM

Quote:

Originally Posted by fris (Post 18477633)
need more descriptive what you want.

but here is the basis




hope this helps you out somewhat.

/members.html use /main is exactly what I wanted. not sure which to use for the next part where I want all urls with .html to have the alias of there filename ... whatever.html would be /whatever

fris 10-08-2011 04:32 PM

that will work then, i used to use something like that for arylia, since tgps didnt like .php files being submitted, i aliased .html to .php

acctman 10-09-2011 08:44 AM

Quote:

Originally Posted by fris (Post 18478366)
that will work then, i used to use something like that for arylia, since tgps didnt like .php files being submitted, i aliased .html to .php

thanks. how did you become so good with htaccess mod_rewrites?

georgeyw 10-09-2011 01:20 PM

Quote:

Originally Posted by acctman (Post 18479298)
thanks. how did you become so good with htaccess mod_rewrites?

:1orglaugh :1orglaugh :1orglaugh :1orglaugh

http://www.generateit.net/mod-rewrite/

fris 10-09-2011 06:42 PM

Quote:

Originally Posted by georgeyw (Post 18479819)
:1orglaugh :1orglaugh :1orglaugh :1orglaugh

http://www.generateit.net/mod-rewrite/

never found a generator to do many of the stuff I do

Code:

# enables domain.com/search/search-term.html

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^search/(.+)\.html$ /index.php?s=$1 [QSA,L]

Code:

# make /pics/askj12.jpg work as /askj12.jpg

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/data%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/data%{REQUEST_URI} -d
RewriteRule !^pics(/.*)?$ /pics%{REQUEST_URI} [QSA,L]

Code:

# from: http://www.example.com/profile.php?user=username
# to: http://username.example.com

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteRule ^$ /profile.php?user=%1 [QSA,L]

Code:

# rewrite rules to generate on the fly

# /sub/evil.domain.com/pics --> http://evil.domain.com/pics
# /sub/content.domain2.com/clicks --> http://content.domain2.com/clicks
# /sub/ab.domain3.com/moo --> http://ab.domain3.com/moo

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?[^\.]+\.[^\.]+$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ http://%2%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*\.)([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
RewriteRule ^(.*)$ http://%2/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.)?[^\.]+\.[^\.]+$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+\.[^\.]+\.[^\.]+)$ [NC]
RewriteCond %1:::%{REQUEST_URI} !^(.+):::/sub/\1(/.*)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sub/%1/ -d
RewriteRule ^(.*)$ /sub/%1/$1 [QSA,L]

:thumbsup


All times are GMT -7. The time now is 04:37 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123