User
Pass
2FA
 
 

Cineva .htaccess ??

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database
Author Message1165
icezone

[Mentally Stable]



Status: Offline
(since 13-04-2020 17:12)
Joined: 31 Jul 2009
Posts: 59, Topics: 23
Location: C:\windows\HERE

Reputation: 239.4
Votes: 8

Post Posted: 08-05-2015, 22:21:24 | Translate post to: ... (Click for more languages)

Salut !
Am migrat decurand pe WP , dar acum am o problema cu fosturile linkuri .
pe vechiul script aveam link : domeniu.tld/video/id/titlul-cu-minus
intrebarea e cum pot sa redirectionez vechile linkuri in search cu titlul din link
ex : domeniu.tld/?s=titlul+cu+minus ???

Multumesc anticipat ![list]


hast
0 0
  
Back to top
View user's profile Send private message
Raster

[ACNA]



Status: Offline
(since 02-09-2016 09:51)
Joined: 24 Feb 2011
Posts: 5377, Topics: 210
Location: In my mind palace

Reputation: 765.4
Votes: 81

     
Post Posted: 09-05-2015, 13:18:04 | Translate post to: ... (Click for more languages)

Quote:
Patterns and Replacements

The rule above allows you to redirect requests for a single URL, but the real power of mod_rewrite comes when you start to identify and rewrite groups of URLs based on patterns they contain.

Let's say you want to change all of your site URLs as described in the first pair of examples above. Your existing URLs look like this:

http://www.pets.com/show_a_product.php?product_id=7
And you want to change them to look like this:

http://www.pets.com/products/7/
Rather than write a rule for every single product ID, you of course would rather write one rule to manage all product IDs. Effectively you want to change URLs of this format:

http://www.pets.com/show_a_product.php?product_id={a number}
And you want to change them to look like this:

http://www.pets.com/products/{a number}/
In order to do so, you will need to use "regular expressions". These are patterns, defined in a specific format that the server can understand and handle appropriately. A typical pattern to identify a number would look like this:

[0-9]+
The square brackets contain a range of characters, and "0-9" indicates all the digits. The plus symbol indicates that the pattern will idenfiy one or more of whatever precedes the plus - so this pattern effectively means "one or more digits" - exactly what we're looking to find in our URL.

The entire "pattern" part of the rule is treated as a regular expression by default - you don't need to turn this on or activate it at all.

RewriteRule ^products/([0-9]+)/?$ show_a_product.php?product_id=$1 [NC,L] # Handle product requests
The first thing I hope you'll notice is that we've wrapped our pattern in brackets. This allows us to "back-reference" (refer back to) that section of the URL in the following "substitution" section. The "$1" in the substitution tells Apache to put whatever matched the earlier bracketed pattern into the URL at this point. You can have lots of backreferences, and they are numbered in the order they appear.

And so, this RewriteRule will now mean that Apache redirects all requests for domain.com/products/{number}/ to show_a_product.php?product_id={same number}.



Cred ca asta te intereseaza, if not, explica mai bine ca nu inteleg nimic.



воронья
0 0
  
Back to top
View user's profile Send private message
icezone

[Mentally Stable]



Status: Offline
(since 13-04-2020 17:12)
Joined: 31 Jul 2009
Posts: 59, Topics: 23
Location: C:\windows\HERE

Reputation: 239.4
Votes: 8

Post Posted: 09-05-2015, 17:59:07 | Translate post to: ... (Click for more languages)

nu e ce cautam dar cred ca o sa mearga
multumesc


hast
0 0
  
Back to top
View user's profile Send private message
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Freakz Forum Index -> Trash Bin -> Trash -> Programming / Scripting / Database  


The time now is 11-11-2024, 15:26:40
Copyright info

Based on phpBB ro/com
B

 
 
 







I forgot my password