Hi, I need to solve this: site.com/word/24/7?page=2 should become something like /wordlist/show.php?word=24/7&page=2 note the / ! the part "24/7" could be anything, in fact I already have good rules but they do not work with slashes. This is my last attempt: RewriteRule ^words/(.+)$ /wordlist/show.php?word=$1 [L] (where page=2 is sent with the html link) It's the whole day I'm trying this and I have no idea how to solve it. RewriteRule ^words/(.+)\?page=2 /..... seems not to work either.
shouldn't be that hard ([a-zA-Z0-9]+[/]?) try that for the 24/7 , going off the top my hard, but think it should be what you are looking for
Yeah someting like that: RewriteRule ^words/([a-zA-Z0-9\-/]+)\?page=(.*)$ /wordlist/show.php?word=$1&page=$2 [L] Code (markup):
ma0 and evera, you cannot match the query string in the RewriteRule pattern. Use the QSA flag to append the query string to the rewritten URL: RewriteRule ^words/(.+)$ /wordlist/show.php?word=$1 /wordlist/show.php?word=$1 [QSA,L] That rewrites /words/test?page=2 , /wordlist/show.php?word=test&page=2 But, while you are already using mod_rewrite, why not make the page links friendly too? RewriteRule ^words/(.+)(/page([0-9]+))?$ /wordlist/show.php?word=$1&page=$3 /wordlist/show.php?word=$1 [L] That matches /words/test , /words/test/page2 etc.
Krt, I haven't checked your code yet, but my problem is that some words contains slashes "24/7" can't be used with simple rewrite rules. I would love to be able to do so, but how can Apache recognize /word/myword/2 (or /word/myword/page2 as you said) and /word/24/7/2 ? I should probably have something complicated like a "lastIndexOf("/") to find out the last / and use the slashes before in the words. I wanted to SEOize it but if I can't, I think I will probably have to do a search on all my words and change the / with something different. Edit: Thinking about it, I think I need to find a way to be able to use /word/24/7/2 or find a substitute for the /, otherwise google will index only my first page. HELP
That's why I used "page#" instead of just "#" I don't think .htaccess alone would be enough to identify 24/7 as an item instead of the 7th page of the item "24". This could be solved by using ref's for your content items with special characters and spaces that are ill suited to URLs substituted. I use a hyphen for this. Anyway, back to what I was saying, using page# means the rewrite rule I posted will differentiate properly, e.g. /words/24/7 will go to ...?word=24/7 /words/24/7/page2 will go to ...?word=24/7&page=2
I should try the other road.. I want google to see all my pages. Maybe I should try the hyphen thing. The problem is that I have no idea which character is NOT used by all the words. I could have words with ~, / ..even ? .. I was thinking to urlencode them, but that doesn't solve the problem.
Google will see all the pages using my method and will have less problems than using query strings. As for the other issue, I mean this: have a reference version for each word, e.g: ref | word apple | apple 24-7 | 24/7 ping-pong | ping-pong
I don't get what you mean with reference. where do you have it? I have no idea on what word I'll be using. That's the problem. And I could have the word 24/7 and the word 24-7 too.
I meant a different version of the word without any special characters that references the actual word. Just an idea though.
Thanks for the ideas. I will try them tonight. The references will never work though. Look at my blog to see what I'm doing and you'll see why. I do not decide which word exists or not, so I could have 247 24-7 24/7 24?7 on the Db.
KRT,sorry for the delay. I tried today and your .httacces rule doesn't work. It takes the whole word AND /pageX as a word so I get word="myword/page2" and page="" Apparently there isnt a solution for that.
Sorry, I have been absent from these forums for the last 2 to 3 weeks. There is a solution as shown here, the problem was a missing ? to signify ungreedy behaviour. RewriteRule ^words/(.+?)(/page([0-9]+))?$ /wordlist/show.php?word=$1&page=$3 /wordlist/show.php?word=$1 [L]
I will try it then. Are you sure of what you write? I've never seen a RewriteRule with two "destination" (how do you call the second part of the rule?)