Forum Moderators: phranque

Message Too Old, No Replies

301 redirect how-to question

changing video script to a different video script

         

crunchyroll

5:21 am on Jul 2, 2012 (gmt 0)

10+ Year Member



This is my original htaccess:

RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Main Menu Links #
RewriteRule ^videos/load/([^/]*)$ seemore.php?load=$1 [L]
RewriteRule ^videos/load/([^/]*)/([^/]*)$ seemore.php?load=$1&page=$2 [L]

RewriteRule ^audios/load/([^/]*)$ audio.php?load=$1 [L]
RewriteRule ^audios/load/([^/]*)/([^/]*)$ audio.php?load=$1&page=$2 [L]

RewriteRule ^audio/album/([^/]*)/([^/]*)$ audio.php?album=$1 [L]
RewriteRule ^audio/album/([^/]*)/([^/]*)/([^/]*)$ audio.php?album=$1&page=$3 [L]

RewriteRule ^blogs/load/([^/]*)$ blogs.php?load=$1 [L]
RewriteRule ^blogs/load/([^/]*)/([^/]*)$ blogs.php?load=$1&page=$2 [L]

RewriteRule ^albums/load/([^/]*)$ albums.php?load=$1 [L]
RewriteRule ^albums/([^/]*)/([^/]*)$ albums.php?load=$1&page=$2 [L]

RewriteRule ^people_ajax people_ajax.php [L]
RewriteRule ^people/([^/]*)/([^/]*)$ people.php?load=$1&page=$2 [L]
RewriteRule ^people people.php [L]
RewriteRule ^upload-media upload.php [L]

RewriteRule ^groups$ groups.php [L]
RewriteRule ^search search.php [L]


# Action Links #
RewriteRule ^videos-([0-9]*)-(.*) play.php?vid=$1 [R=301,L]
RewriteRule ^videos/([^/]*)/([^/]*)$ play.php?vid=$1 [L]
RewriteRule ^audio/([^/]*)/([^/]*)$ play_audio.php?audio=$1

RewriteRule ^category/([^/]*)$ category_home.php?cid=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)$ category_home.php?cid=$1&page=$2 [L]

RewriteRule ^subcategory/([^/]*)/([^/]*)$ category_home.php?sub=$1 [L]
RewriteRule ^subcategory/([^/]*)/([^/]*)/([^/]*)$ category_home.php?sub=$1&page=$3 [L]

RewriteRule ^genre/([^/]*)$ genre_home.php?cid=$1 [L]
RewriteRule ^genre/([^/]*)/([^/]*)$ genre_home.php?cid=$1&page=$2 [L]

RewriteRule ^view-album/([^/]*)/([^/]*)$ album_view.php?album=$1
RewriteRule ^view-image/([^/]*)/([^/]*)$ album_view.php?image=$1
RewriteRule ^read_blog/([^/]*)/([^/]*)$ read_blog.php?id=$1 [L]

RewriteRule ^blogs/category/([^/]*)/([^/]*)$ blogs.php?cat_id=$1 [L]
RewriteRule ^blogs/category/([^/]*)/([^/]*)/([^/]*)$ blogs.php?cat_id=$1&page=$3 [L]

RewriteRule ^members/([^/]*)$ memberprofile.php?user=$1 [L]

#-------------------------------------------------------------#
# redirect directory browsing attempts
RewriteRule ^videos(.?)$ seemore.php [L]
RewriteRule ^audios(.?)$ audio.php [L]
RewriteRule ^blogs(.?)$ blogs.php [L]
RewriteRule ^members(.?)$ people [R=301]
RewriteRule ^albums(.?)$ albums.php [L]

#-------------------------------------------------------------#

#--------------------------------------- END SEO ----------------------------------------#


#--------------------------------------- SOME SIMPLE BLOCKS -----------------------------#
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [F,L]
#--------------------------------------- END BLOCKS -------------------------------------#


This is my new htaccess file

#<IfModule mod_security.c>
# secfilterengine off
# secfilterscanPOST off
#</IfModule>

Options All -Indexes
FileETag MTime Size
Options +FollowSymlinks
RewriteEngine on

<FilesMatch "\.(db|inc|tmpl|h|ihtml|sql|ini|configuration|config|class|bin|spd|theme|module|cfg|cpl|tmp|log|err|i nc.php|class.php)$">
order allow,deny
satisfy all
</FilesMatch>

########## Begin - Rewrite rules to block out some common exploits
#

# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]

# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]

# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]

# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

# Send all blocked request to homepage with 403 Forbidden error!
#RewriteRule ^(.*)$ index.php [L]
RewriteRule ^([^.]*)/?$ index.php [L]
#

########## End - Rewrite rules to block out some common exploits





RewriteEngine on

#

#

#

#URL Rewriting for Videos

RewriteRule ^videos/(.*)/(.*)/(.*)/(.*)/(.*) videos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]

RewriteRule ^videos/([0-9]+) videos.php?page=$1 [L]

RewriteRule ^videos/?$ videos.php?%{QUERY_STRING} [L]

RewriteRule ^video/(.*)/(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]

#Alternate watch video links

RewriteRule ^(.*)\_v([0-9]+) watch_video.php?v=$2&%{QUERY_STRING} [L]

RewriteRule ^video/([0-9]+)_(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]





#

#Users, Channel & Management

#



RewriteRule ^channels/(.*)/(.*)/(.*)/(.*)/(.*) channels.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]

RewriteRule ^channels/([0-9]+) channels.php?page=$1 [L]

RewriteRule ^channels/?$ channels.php [L]

RewriteRule ^members/?$channels.php [nc]

RewriteRule ^users/?$channels.php [nc]

RewriteRule ^user/(.*)view_channel.php?user=$1 [nc]

RewriteRule ^channel/(.*)view_channel.php?user=$1 [nc]





RewriteRule ^my_accountmyaccount.php [nc]







#Pages

RewriteRule ^page/([0-9]+)/(.*)view_page.php?pid=$1 [nc]

#

#Miscellenous

RewriteRule ^search/result/?$search_result.php [nc]

RewriteRule ^upload/?$upload.php [nc]

RewriteRule ^contact/?$contact.php [nc]

RewriteRule ^categories/?$categories.php [nc]



#Group Section



RewriteRule ^group/([a-zA-Z0-9].+)view_group.php?url=$1&%{QUERY_STRING} [L]



RewriteRule ^view_topic/([a-zA-Z0-9].+)_tid_([0-9]+)view_topic.php?tid=$2&%{QUERY_STRING} [L]

RewriteRule ^groups/(.*)/(.*)/(.*)/(.*)/(.*) groups.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]

RewriteRule ^groups/([0-9]+) groups.php?page=$1 [L]

RewriteRule ^groups/?$ groups.php [L]

RewriteRule ^create_group create_group.php [L]



#Collection Section

RewriteRule ^collections/(.*)/(.*)/(.*)/(.*)/(.*) collections.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]

RewriteRule ^collections/([0-9]+) collections.php?page=$1 [L]

RewriteRule ^collections/?$ collections.php [L]

RewriteRule ^photos/(.*)/(.*)/(.*)/(.*)/(.*) photos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]

RewriteRule ^photos/([0-9]+) photos.php?page=$1 [L]

RewriteRule ^photos/?$ photos.php [L]

RewriteRule ^collection/(.*)/(.*)/(.*)view_collection.php?cid=$1&type=$2&%{QUERY_STRING} [L]



#Photo Section

RewriteRule ^item/(.*)/(.*)/(.*)/(.*) view_item.php?item=$3&type=$1&collection=$2 [L]

RewriteRule ^photo_upload/(.*) photo_upload.php?collection=$1 [L]

RewriteRule ^photo_upload/?$photo_upload.php [L]

#

RewriteRule ^sitemap.xml$ sitemap.php

RewriteRule ^signup/?$ signup.php



#Error Pages

ErrorDocument 404 /404.php

ErrorDocument 403 /403.php



########## End - Rewrite rules For SEO urls ######################

RewriteRule ^rss$ rss.php [nc]

RewriteRule ^rss/([a-zA-Z0-9].+)$ rss.php?mode=$1&%{QUERY_STRING} [nc]



########## End - Rewrite rules For SEO urls ######################



RewriteRule^([a-zA-Z0-9-]+)/?$ view_channel.php?uid=$1&seo_diret=yes [NS]


Unfortunately, after reading countless sites and how-to's, I am still learning the world of 301 rewrites and only know a few basic ones.

However, I don't plan to rewrite every one of them as I never had them active or crawling on the website except for watching/browsing videos. With that being said, I believe the code below is probably the only ones I need to convert:

# Action Links #
RewriteRule ^videos-([0-9]*)-(.*) play.php?vid=$1 [R=301,L]
RewriteRule ^videos/([^/]*)/([^/]*)$ play.php?vid=$1 [L]

RewriteRule ^category/([^/]*)$ category_home.php?cid=$1 [L]
RewriteRule ^category/([^/]*)/([^/]*)$ category_home.php?cid=$1&page=$2 [L]


Any help would be appreciated on this

lucy24

5:48 am on Jul 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



By the most staggeringly amazing coincidence, it is only a few hours* since I said in another thread
If only there were some middle ground between Not Enough Information and dumping out the entire htaccess (or stylesheet, or ...)


So let's just pick something wholly at random. (Another barefaced lie. I started at the top.)

RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ - [L]

I know what you're trying to do here. You want to screen out the subsidiary files like images and stylesheets so you don't have to think about them during the rest of mod_rewrite. You want all the other rules to apply only to requests for pages or directories. But it's still not the right way to do it. What happens when you need to redirect a stylesheet, or add a hotlinking routine?

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Rewrite Conditions apply only to the immediately following rule, which in this case happens to be
RewriteRule ^videos/load/([^/]*)$ seemore.php?load=$1 [L]

And I know that wasn't your intention. In fact the !-d and !-f pair are rarely necessary at all, and never when your Rule involves a specific filename.


* Oops, no, I tell a lie. It was more than 24 hours-- and has yet to be indexed. Sleeping on the job, google?

g1smd

6:41 am on Jul 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Just dealing with rules that will be handled by mod_rewrite, the rules are in the wrong order.

Rules which block access should be listed first.

You must list all of the redirects next.
The redirects should include the protocol and hostname in the rule target.

Finally you should list all the rewrites.
Most of the rewrite targets should begin with a leading / here.

Within each group you should list from most specific to most general. This means that the last of your redirects will be the non-www/www redirect and the last of your rewrites will be the general rule with (.*) as the patttern.

Once the rules are in the right order, we can look at the syntax and logic errors in various rules. These include changing * to + in many locations, and replacing .* with something much better in many others.

Escape the literal periods in patterns. Every rule should include the [L] flag.

Add a blank line after every RewriteRule.
Do NOT have a blank line after a RewriteCond.
This aids the readability of the file.

We'll deal with the folder/? patterns in rewrites which cause duplicate content, and the (.*)/(.*)/(.*) patterns which are very inefficient, later.

crunchyroll

7:10 am on Jul 2, 2012 (gmt 0)

10+ Year Member



ok thanks for the feedback. I wasn't aware that I would still need to redirect css/images

Like you mentioned, I was just focusing on wanting to redirect the url's that are indexed in the search engines since the are now different.

So From my old htaccess, I will need to insert all of my old rewrites into my new htaccess file as well and then be able to create the rewrite rule for the new htaccess?

crunchyroll

8:12 am on Jul 8, 2012 (gmt 0)

10+ Year Member



I'm still confused, do I need to merge my old htaccess rules onto my new htaccess and then create the rewrite rules from there?

g1smd

9:17 am on Jul 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteRule can be configured to deliver a redirect or to perform an internal rewrite.

I assume you have moved from a custom coded site to one using Joomla.

For the internal rewites found in the old file, I guess you'll need to turn those into redirects if the content is now accessed at a new URL.

crunchyroll

11:02 am on Jul 8, 2012 (gmt 0)

10+ Year Member



It came from one video sharing script to a different kind of video script.

What makes it hard for me to figure out is all the variables since it is SEO rewrites.

My current url looks something like: http://www.example.com/videos/3857/example-page

The new url will look like: http://example.com/example-page_v13865


For categories:
The categories on the current url: http://www.example.com/category/sample

new url: http://example.com/videos/1022/sample/most_recent/all_time/



Since Lucy was stating I can't just rewrite only the specific ones I'm wanting to redirect, I'm wondering if I'm supposed to some how redirect all the old rewrites with the new existing ones. Wouldn't this also clutter the htaccess with so many rewrite rules?

g1smd

11:21 am on Jul 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Some of my htacess files are thousands of lines long.

The mod_rewrite code is usually divided into three major sections:

- rules that block access subdivided by IP, user agent, requested query string and requested path.
- rules that redirect requests to a different URL, firstly old URLs from old sites, then new non-canonical URLs on the new site, both subdivided by query string and by path, etc.
- rules that rewrite incoming external URL requests to fetch the content from the server internal filepath.


Your old site had an internal rewrite like this:
RewriteRule ^upload-media upload.php [L]

When the URL
example.com/upload-media
was requested, the pointer was internally rewritten to fetch the content from
/upload.php
without revealing what that internal location was.

Your new site has this internal rewrite:
RewriteRule ^upload/?$ upload.php [nc]

This uses the same php script as before, but now you allow several different URLs to access it, none of which are the same as the old URL.

You will therefore need to alter the rewrite found on the old site to be a redirect to the new URL.

Additionally, the /? and [nc] in the new rewrite are very unsafe. It allows multiple duplicate content issues:
example.com/upload

example.com/Upload

example.com/uPload

example.com/upLoad

example.com/UPload

example.com/UpLoad

etc
example.com/UPLOAd

example.com/UPLOAD

and
example.com/upload/

example.com/Upload/

example.com/uPload/

example.com/upLoad/

example.com/UPload/

example.com/UpLoad/

etc
example.com/UPLOAd/

example.com/UPLOAD/

are all duplicates.

Remove the /? part. URLs for pages do not end in a trailing slash.
Remove the [nc] flag. Never use the [nc] flag with an internal rewrite. Use it only on an external redirect.

RewriteRule ^upload-media upload.php [L]
(from old file)
...
RewriteRule ^upload/?$ upload.php [nc]
(from new file)

becomes (all in new file)

# Redirect old URLs on old site to new URL on new site
RewriteRule ^upload-media http://www.example.com/upload [R=301,L,NC]

...
# Fix to redirect non-canonical requests on new site to lower-case without slash
RewriteCond %{REQUEST_URI} !^/upload$
RewriteRule ^upload/?$ http://www.example.com/upload [R=301,L,NC]

...
# Rewrite requests (only valid URL is lower case without slash) to serve content
RewriteRule ^upload$ /upload.php [L]

crunchyroll

12:16 pm on Jul 8, 2012 (gmt 0)

10+ Year Member



Thank you for taking the time to clarify and further explain. I will look into this and get back to you with updates.

g1smd

12:36 pm on Jul 8, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is a big job and you're going to need to be very organised to do it.

First thing I would suggest is to comment every block of code and NUMBER the rules in the comments.

crunchyroll

12:27 pm on Jul 10, 2012 (gmt 0)

10+ Year Member



I understood what you meant with duplicate content possiblities:

Additionally, the /? and [nc] in the new rewrite are very unsafe. It allows multiple duplicate content issues:
example.com/upload
example.com/Upload
example.com/uPload
example.com/upLoad
example.com/UPload
example.com/UpLoad
etc
example.com/UPLOAd
example.com/UPLOAD
and
example.com/upload/
example.com/Upload/
example.com/uPload/
example.com/upLoad/
example.com/UPload/
example.com/UpLoad/
etc
example.com/UPLOAd/
example.com/UPLOAD/
are all duplicates.

Remove the /? part. URLs for pages do not end in a trailing slash.
Remove the [nc] flag. Never use the [nc] flag with an internal rewrite. Use it only on an external redirect.

RewriteRule ^upload-media upload.php [L] (from old file)
...
RewriteRule ^upload/?$ upload.php [nc] (from new file)


However, when I tested it, in its original rule, the page will go to a 404 error trying case sensitive variations.

-------------------------------
My original attempt was to just redirect the major necessary links. The other rewrites from the old htaccess wasn't used and I felt it wasn't necessary to implement it into the new htaccess. I don't know if I did it correctly, but this is what I came up with so far.


#<IfModule mod_security.c>
# secfilterengine off
# secfilterscanPOST off
#</IfModule>


Options All -Indexes
FileETag MTime Size
Options +FollowSymlinks
RewriteEngine on

<FilesMatch "\.(db|inc|tmpl|h|ihtml|sql|ini|configuration|config|class|bin|spd|theme|module|cfg|cpl|tmp|log|err|inc.php|class.php)$">
order allow,deny
satisfy all
</FilesMatch>

### 1. Old Script - Redirect css, extensions, filenames ###
#RewriteRule \.(css|jpe?g|gif|png|flv|swf)$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
### END REDIRECT CSS, EXTENSIONS, FILENAMES ###

########## Begin - Rewrite rules to block out some common exploits
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
#RewriteRule ^(.*)$ index.php [L]
RewriteRule ^([^.]*)/?$ index.php [L]
#
########## End - Rewrite rules to block out some common exploits

RewriteEngine on
#
#
#

#



#URL Rewriting for Videos

### 2. Action Links - OLD SCRIPT REDIRECT VIDEO URLS ###
# 2.1 RewriteRule ^videos-([0-9]*)-(.*) play.php?vid=$1 [R=301,L]
# 2.2 RewriteRule ^videos/([^/]*)/([^/]*)$ play.php?vid=$1 [L]

RewriteRule ^videos/(.*)/(.*)/(.*)/(.*)/(.*) videos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
### 3. REDIRECT VIDEO CATEGORIES ###
# RewriteRule ^category/([^/]*)$ category_home.php?cid=$1 [L]
# RewriteRule ^category/([^/]*)/([^/]*)$ category_home.php?cid=$1&page=$2 [L]
### END REDIRECT VIDEO CATEGORIES ###
RewriteRule ^videos/([0-9]+) videos.php?page=$1 [L]
RewriteRule ^videos/?$ videos.php?%{QUERY_STRING} [L]
RewriteRule ^video/(.*)/(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]


#Alternate watch video links
RewriteRule ^(.*)\_v([0-9]+) watch_video.php?v=$2&%{QUERY_STRING} [L]
RewriteRule ^video/([0-9]+)_(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]
#

#Users, Channel & Management
#
RewriteRule ^channels/(.*)/(.*)/(.*)/(.*)/(.*) channels.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^channels/([0-9]+) channels.php?page=$1 [L]
RewriteRule ^channels/?$ channels.php [L]
RewriteRule ^members/?$channels.php [nc]
RewriteRule ^users/?$channels.php [nc]
RewriteRule ^user/(.*)view_channel.php?user=$1 [nc]
RewriteRule ^channel/(.*)view_channel.php?user=$1 [nc]
RewriteRule ^my_accountmyaccount.php [nc]

#Pages
RewriteRule ^page/([0-9]+)/(.*)view_page.php?pid=$1 [nc]
#

#Miscellenous
RewriteRule ^search/result/?$search_result.php [nc]
RewriteRule ^upload/?$upload.php [nc]
RewriteRule ^contact/?$contact.php [nc]
RewriteRule ^categories/?$categories.php [nc]


#Group Section
RewriteRule ^group/([a-zA-Z0-9].+)view_group.php?url=$1&%{QUERY_STRING} [L]
RewriteRule ^view_topic/([a-zA-Z0-9].+)_tid_([0-9]+)view_topic.php?tid=$2&%{QUERY_STRING} [L]
RewriteRule ^groups/(.*)/(.*)/(.*)/(.*)/(.*) groups.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^groups/([0-9]+) groups.php?page=$1 [L]
RewriteRule ^groups/?$ groups.php [L]
RewriteRule ^create_group create_group.php [L]

#Collection Section
RewriteRule ^collections/(.*)/(.*)/(.*)/(.*)/(.*) collections.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^collections/([0-9]+) collections.php?page=$1 [L]
RewriteRule ^collections/?$ collections.php [L]
RewriteRule ^photos/(.*)/(.*)/(.*)/(.*)/(.*) photos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^photos/([0-9]+) photos.php?page=$1 [L]
RewriteRule ^photos/?$ photos.php [L]
RewriteRule ^collection/(.*)/(.*)/(.*)view_collection.php?cid=$1&type=$2&%{QUERY_STRING} [L]

#Photo Section
RewriteRule ^item/(.*)/(.*)/(.*)/(.*) view_item.php?item=$3&type=$1&collection=$2 [L]
RewriteRule ^photo_upload/(.*) photo_upload.php?collection=$1 [L]
RewriteRule ^photo_upload/?$photo_upload.php [L]
#

RewriteRule ^sitemap.xml$ sitemap.php
RewriteRule ^signup/?$ signup.php



#Error Pages
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php


### 3. SIMPLE BLOCKS REDIRECT - OLD SCRIPT ###
#--------------------------------------- SOME SIMPLE BLOCKS -----------------------------#
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteCond %{QUERY_STRING} SELECT(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} UNION(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteRule ^(.*)$ index.php [F,L]
#--------------------------------------- END BLOCKS -------------------------------------#
### END SIMPLE BLOCKS REDIRECT - OLD SCRIPT ###

########## End - Rewrite rules For SEO urls ######################

RewriteRule ^rss$ rss.php [nc]
RewriteRule ^rss/([a-zA-Z0-9].+)$ rss.php?mode=$1&%{QUERY_STRING} [nc]

########## End - Rewrite rules For SEO urls ######################

RewriteRule^([a-zA-Z0-9-]+)/?$ view_channel.php?uid=$1&seo_diret=yes [NS]


I'm still confused as to why I would be required to have all my old rewrites implemented onto the new htacess, when majority were never used. If anything, all the other new redirects, I was just planning to have it point to the main url. Let me know if I have done it correctly so far, and what my next steps should be.

Thanks

lucy24

5:20 pm on Jul 10, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



when I tested it, in its original rule, the page will go to a 404 error trying case sensitive variations.

It's supposed to. Each page has exactly one name, case sensitive. If you have pages that are known to the world by more than one URL-- case sensitive-- you will need to Redirect to the preferred form.

It's really the same principle as using a domain name with or without www. You can easily set up the site to recognize both, but then g### will think there are two of you with matching sites.

item/(.*)/(.*)/(.*)/(.*)

Y'know, I haven't even read every word of this thread, but I KNOW g1 must have read you the riot act about this form. See, the simple dot . includes everything-- not just the alphanumerics, lowlines and hyphens that will occur in file or directory names, but also directory slashes and literal periods. You definitely don't want an asaterisk * no matter what it's attached to, because that would allow URLs in the form

item////

or, for that matter,

item/./././././././

crunchyroll

11:07 pm on Jul 10, 2012 (gmt 0)

10+ Year Member



I actually didn't do much of the writing on these rules, so it appears the original developer of this script probably did.

Just out of curiosity, how much would something like this cost to convert/rewrite the rules to the new htaccess?