Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Need a bit of help with this one. I want to strip the query from an url and rewrite the remaining part.
This is the current url
http://www.example.com/catold/catname/page/7?gdsr_sort=rating&gdsr_order=desc
and want to rewrite it to
http://www.example.com/catnew/catname/page/1
Thanks
Try this rule:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^catnew/catname/page/[0-9]+/?$ %{REQUEST_URI}?gdsr_sort=rating&gdsr_order=desc [L,R]
you can use str.split("?")... it will split string by ? and you get strings array and
var str = "http://www.example.com/catold/catname/page/7?gdsr_sort=rating&gdsr_order=desc";
var stringArry = str.split("?");
// stringArray[0] will be the string what you want...
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am new to apache web server.
I have a URL like :-
www.example.com/example1/{ dynamic string }/p123465/content
I want to convert it into:
www.example.com/example1/{ dynamic string }/pid/content
here dynamic string is different every time.
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^(example1/[^/]+)/p123465/(content)/?$ /$1/pid/$1 [L,NC,R]
Or if you already have /example1/.htaccess then use
RewriteEngine On
RewriteBase /example1/
RewriteRule ^([^/]+)/p123465/(content)/?$ $1/pid/$1 [L,NC,R]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I've installed a photo script in a sub-folder(photos) on my site.
The script doesn't work when I go to www.domain.com/photos/ only works when i go to www.domain.com/photos/public/gallery/.
Can someone please help me with the code I would use in my .htaccess file to have www.domain.com/photos/ as the main link?
Thank You
Put this code in your DOCUMENT_ROOT/photos/.htaccess file:
RewriteEngine On
RewriteBase /aviation-photos/
RewriteRule ^$ public/gallery [L]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is it possible to alter my search result url say from this:
/search.php?query=Currys
To something more search engine friendly and also add to it so that it becomes something like this:
/search-results-for-Currys-Voucher-Codes
By using htaccess?
Thanks.
You can probably do something like this by placing this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+search\.php\?query=([^\s&]+) [NC]
RewriteRule ^ /search-results-for-%1? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^search-results-for-(.+?)/?$ /search.php?query=$1 [L,QSA,NC,NE]
Then inside search.php get your parameters as $_GET['query']
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Im a bit lost with htaccess Files and regexp exceptions...
how can I make a htaccess denying access to files that are like : #.jpg where # is one or more digit?
1.jpg ->deny
25.jpg ->deny
74_thumb ->allow
22_400 -> allow
14254.jpg ->deny
I'm looking for the correct regexp syntax to differentiate the number only to another filename.
I've found out that this can be done with htaccess files and rewrite conditions, or deny with exceptions but can't find a concrete example of how this is done.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
RewriteEngine On
RewriteRule (^|/)[0-9]+\.jpe?g$ - [F,NC]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to 301 redirect to all my URLs who have a specific pattern.
Old URLs are like
http://www.example.in/1231/ask-meaning-in-hindi
http://www.example.in/1233/blow-meaning-in-hindi
http://www.example.in/1235/beyond-meaning-in-hindi
I want to redirect them to a pattern like this:
http://www.example.in/1231/ask
http://www.example.in/1233/blow
http://www.example.in/1235/beyond
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+/[^-]+)-.+$ /$1 [L,R=301]