Jump to content

Adding an additional option/Exception to working rewrite


scs

Recommended Posts

So my problem is probably simple I just don't understand htaccess very well.

 

Here's the original working rewrite

Options +FollowSymlinks

RewriteEngine on

RewriteBase /manga/

RewriteRule ^mangas/([^/]+)/([^/]+)/$ - [F,L]
RewriteRule ^mangas/([^/]+)/$ - [F,L]
RewriteRule ^mangas(/?)$ - [F,L]

RewriteRule ^([^/.]+)/([^/.]+)/([0-9]+)(/?)$ index.php?manga=$1&chapter=$2&page=$3 [L]
RewriteRule ^([^/.]+)/([^/.]+)(/?)$ index.php?manga=$1&chapter=$2 [L]
RewriteRule ^([^/.]+)(/?)$ index.php?manga=$1 [L]

Note the "mangas" folder is where the chapters are (Root/manga/mangas/Naruto/)

 

resulting in:

http://www.mysite.com/manga/

http://www.mysite.com/manga/Naruto

http://www.mysite.com/manga/Naruto/001/

http://www.mysite.com/manga/Naruto/001/2  (page 2)

 

now what I have run into is some chapters have 001.5

http://www.mysite.com/manga/Naruto/001.5/

That gives me a 404 on my server. I want to either change the whole rewrite or add the option for this variant.

 

I already tried this below. and it does not work.

Original  RewriteRule ^([^/.]+)/([^/.]+)/([0-9]+)(/?)$ index.php?manga=$1&chapter=$2&page=$3 [L]

Mine      RewriteRule ^([^/.]+)/([^/.]+)/([0-9]+).([0-9])(/?)$ index.php?manga=$1&chapter=$2&page=$3 [L]

taking note to this .............................................^^^^  I also tried that with the plus  ([0-9]+) and still did not work

and I did not replace the original line. I added my line right below.

 

Now for the ([0-9]+) part. I might have some mangas (later on) that might have 001.a. Would it b possible to just change ([0-9]+) to ([^/.]+)

then that way I could just skip the whole "adding .5 .a" and just grab all the of chars between the / /

or would that cause the whole rewrite to fall apart?

I figured I would ask that before I try it.

 

Hope that all made sense. getting tired after working on the site all day >.<

would be thankful for any advice on the subject

Thanks!

Link to comment
Share on other sites

cant edit my post..

for the part where I want to "change ([0-9]+) to ([^/.]+)"

I mean like this:

Options +FollowSymlinks

RewriteEngine on

RewriteBase /manga/

RewriteRule ^mangas/([^/]+)/([^/]+)/$ - [F,L]
RewriteRule ^mangas/([^/]+)/$ - [F,L]
RewriteRule ^mangas(/?)$ - [F,L]

RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)(/?)$ index.php?manga=$1&chapter=$2&page=$3 [L]            <<< note the change on this line from the original
RewriteRule ^([^/.]+)/([^/.]+)(/?)$ index.php?manga=$1&chapter=$2 [L]
RewriteRule ^([^/.]+)(/?)$ index.php?manga=$1 [L]

Link to comment
Share on other sites

So I went ahead and tested the code in my second post. Everything works the same but when ever I try to access a link like:

http://www.mysite.com/manga/Naruto/001.5/

I still get a 404

 

any advice to point me in the direction so I can figure this out would be extremely helpful!

The trouble it would cause to "simply" rename the folders so I don't have .5 would take weeks..  :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.