Default url view looks like this: https://example.com/user.php?page=history
I change it with .htaccess to: https://example.com/user/history/
Problem in navigation bar which I made with radio type form. And it gives me: https://example.com/user/history/?page=history
How to change it? Help pls.
.htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^user/(\w+)$ /user.php?p=$1
RewriteRule ^user/(\w+)/$ /user.php?p=$1
<form name='page' id='page'>
<input id="history" type="radio" name="page" <?php if ($p == 'history') { ?>checked='checked' <?php } ?> onChange="autoSubmit();" value="history" >
<label for="history">Історія замовлень</label>
<input id="settings" type="radio" name="page" <?php if ($p == 'settings') { ?>checked='checked' <?php } ?>onChange="autoSubmit();" value="settings">
<label for="settings">Налаштування</label>
</form>
<script>
function autoSubmit(){
var formObject=document.forms['page'];
formObject.submit();}
</script>
<?php
$p="";
if(isset($_GET["page"])){
$p=$_GET["page"];
}
?>
Radio type menu needs to be like this:
EDIT: Please try following rules as per shown samples in comments.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/]*)/([^/]*)/?$ user.php?page=$1 [L]
With your shown attempts, please try following htaccess Rules file, make sure your php file(s) and htaccess are in same folder. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##Doing external rewrite to friendly url here.
RewriteCond %{THE_REQUEST} \s/(.*)/?\?page=([\w-]+)\s [NC]
RewriteRule ^ /%1/%2 [QSD,R=301,L,NE]
##Doing internal rewrite to php files here.
RewriteRule ^(?:[^/]*)/([^/]*)/?$ user.php?page=$1 [QSA,L]
Related
Hi there i am working on SEO friendly URLs here is who my url look alike
http://localhost/richmedia/format/?id=Jazz-Cash-HTML-5-Polite-Billboard
This is the part where i am sending request with get method
<form method="GET" action="format/" target="_blank">
<button class="btn btn-primary btn-block" type="submit" >Preview</button>
<input type="hidden" value="'.$seo_title.'" name="id">
</form>
this is what i write in .htacces file
RewriteEngine On
RewriteRule ^creative-zone$ index.php [NC,L]
RewriteRule ^agencies$ agencies.php [NC,L]
RewriteRule ^advertisers$ advertisers.php [NC,L]
RewriteRule ^about-us$ about.php [NC,L]
RewriteRule ^format/?$ format.php?id=$1 [NC,L]
RewriteRule ^(.*)format/([0-9a-zA-Z_-]+)$ format.php?id=$1 [NC,L]
i want to remove this "?id="section from my url. Every Thing is working fine But this ?id= need to be fixex. Need Help. Thanks in advance.
You want to make sure the application still handles the parameter correctly but the answer is fairly straight forward:
RewriteRule ^([0-9A-Za-z_-])?$ index.php?yourparam=$1 [NC,L]
In other words, look for a string after the root, then convert that to an id on the server side.
However when generating the links you'll need to address the id= 'thing'
Your links might look like
link to stuff
which would then be converted to
?id=my_foo_bar
I try some code examples from stackoverflow, but nothing seems to work.
So I have <img src="http://external-url.com/image.png" /> and I want to show not-found.png from my server if http://external-url.com/image.png doesn't exists.
Can I do that ?
You can use this rule in your site root .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(png|jpe?g|tiff|gif)$ /path/to/not-found.png [L,NC]
Change /path/to/not-found.png to your actual path of not-found.png.
I made a website using Yeoman; grunt , generator-angular, $routeParams ... with Node.js just to build my application , how do I use the prerenderor seo4ajax and index it?
Using Node.js as an application server could set like this:
Run this on the command line: $ npm install prerender-node --save
And when you set up your express app...: app.use(require('prerender-node'));
But, I use Node.js only to build my application, i do not have express this app, how do I install and configure nginx (I use hosting Godaddy ) to get index the content of my site?
Google provides some tools that make content indexing in ajax , now my site is appearing in search engine/research.
Go to: https://www.google.com/webmasters/tools/googlebot-fetch?hl=
Add a site , then go to trace > Fetch as Google and enter the pages you want to render and then index. There are many other excellent tools that site to assist us in indexing content in Ajax .
More info: https://support.google.com/webmasters/answer/6066467?hl=en
Yannick 's SEO4Ajax provided these modules to .htaccess and social networks functioned: Replace yousite with the name of your domain , replace put you token by his token (to get the token register at: seo4ajax.com ) then copy and paste in your .htaccess.
<IfModule mod_headers.c>
RequestHeader set Host "api.seo4ajax.com"
</IfModule>
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options +FollowSymLinks
# Redirect yousite.com to www.yousite.com
RewriteCond %{HTTP_HOST} ^yousite\.com [NC]
RewriteRule ^(.*) http://www.yousite.com/$1 [L,R=301]
<IfModule mod_proxy_http.c>
# If requested with the _escaped_fragment_ query parameter, proxify
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !(index.html) [NC]
RewriteCond %{QUERY_STRING} _escaped_fragment_= [NC]
RewriteRule .* - [E=PROXIFY:true]
# If requested by a bot that does not support the specification, proxify
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !(index.html) [NC]
RewriteCond %{HTTP_USER_AGENT} !(google.*bot|bing|msnbot|yandexbot|pinterest.*ios|mail\.ru) [NC]
RewriteCond %{HTTP_USER_AGENT} (bot|crawler|spider|archiver|pinterest|facebookexternalhit|flipboardproxy) [NC]
RewriteRule .* - [E=PROXIFY:true]
# Proxification to SEO4Ajax
RequestHeader set Host "api.seo4ajax.com" env=PROXIFY
RewriteCond %{ENV:PROXIFY} true
RewriteRule ^(.*)$ http://api.seo4ajax.com/put you token/$1 [P,QSA,L]
</ifModule>
# html5 pushstate enable
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
</ifModule>
Pass the information from your array for schemas and meta property .
Put that schemas and meta property in their views.
<div ng-repeat="item in grupo">
<!-- Schemas -->
<div span itemscope itemtype="http://schema.org/Article"></span>
<span itemprop="name" content="{{item.title}}"></span>
<span itemprop="description" content="{{item.description}}"></span>
<span itemprop="articleSection" content="Humor"></span>
<span itemprop="image" content="http://www.yousite.com/images/{{item.img}}" ></span>
</div>
<!-- End - Schemas -->
<!-- Meta property -->
<meta property="og:title" content="{{item.title}}" />
<meta property="og:image" content="http://www.yousite.com/images/{{item.img}}" />
<meta property="og:description" content="{{item.description}}" />
<!-- End - Meta property -->
</div>
For instance I have a file php, index.php with content as below:
<ul>
<li>Menu</li>
<li>How it work</li>
</ul>
And I writed .htaccess as below:
RewriteEngine On
RewriteRule ^menu/?$ menu.php
RewriteRule ^how-it-work/?$ howitwork.php
But if I type localhost/menu or localhost/how-it-work it ok, But I want to see link under Menu and How it work also be writed to /menu and /how-it-work, currently it still menu.php and howitwork.php
Another issue, if I have file product.php?action=view&id=123, how could I use htaccess to change it to this localhost/product/123-name-of-topic/
I code and tested on localhost before make it live.
Thanks!
Sorry i cant understand your question first of all,
the final issue could be solved by using a post method in your form instead of get,
<form action="home.php" method="post">
....
....
</form>
Hope this helps.
If I understood right, here is an example:
MODIFIED
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*howitwork.*$
RewriteRule .* http://mydomain.com/how-it-work [L,R=301]
RewriteCond %{REQUEST_URI} ^.*menu.*$
RewriteRule .* http://mydomain.com/menu [L,R=301]
I'm having a really, really, really weird problem on my vBulletin board using Facebook's Like Button. In my thread template I'm using the following code, which is located inside body tag:
<td class="vbs_forumdata alt1">
<div id="fb-root"></div>
<script type="text/javascript">(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id))return;js=d.createElement(s);js.id=id;js.src="//connect.facebook.net/en_US/all.js#xfbml=1";fjs.parentNode.insertBefore(js,fjs)})(document,"script","facebook-jssdk");</script>
<div id="thread_sharing_content_facebook">
<div class="fb-like" data-href="{vb:raw sharingurl}" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90"></div>
</div>
</div>
</td>
As soon as the template is processed by the vBulletin engine, the variable {vb:raw sharingurl} is replaced by the thread's canonical URL, that looks like this:
http://MYDOMAIN/threads/THREADID-THREADTITLE
For example:
http://www.mydomain.com/threads/1-Hello-Community
Looking at the HTML source of a thread page, everything seems to work as intended:
<td class="vbs_forumdata alt1">
<div id="fb-root"></div>
<script type="text/javascript">(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id))return;js=d.createElement(s);js.id=id;js.src="//connect.facebook.net/en_US/all.js#xfbml=1";fjs.parentNode.insertBefore(js,fjs)})(document,"script","facebook-jssdk");</script>
<div id="thread_sharing_content_facebook">
<div class="fb-like" data-href="http://www.mydomain.com/threads/1-Hello-Community" data-layout="button_count" data-send="false" data-show-faces="false" data-width="90"></div>
</div>
</div>
</td>
But then, if I click on the Like Button to share the thread page... here comes the drama:
The original URL of the thread page is messed up transformed into something like:
http://MYDOMAIN/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/THREADID-THREADTITLE
Anyone knows why I'm getting that strange problem? The only thing I was thinking about trying to figure it out by myself, is my htaccess file which contains some rewrite rules. It's almost the vBulletin default one... but, anyway, here they are:
RewriteEngine On
RewriteBase /
// Block Bad Bots
RewriteCond %{HTTP_USER_AGENT} [...]
RewriteRule ^.*$ - [F,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^threads/.* showthread.php [QSA]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ - [NC,L]
RewriteRule ^(.*)$ - [R=404,L]
EDIT: I tried using the Facebook URL debugger and...
Scrape Information
Response Code: 200
Fetched URL: http://www.mydomain.com/threads/1-Hello-Community
Canonical URL: http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
Critical Errors That Must Be Fixed
Could Not Follow Redirect Path: Using data from http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community because there was an error following the redirect path.
Errors That Must Be Fixed
Too Many Redirects: URL redirected too many times. Please reduce the number of redirects.
Like Button Warnings That Should Be Fixed
Admins And App ID Missing: fb:admins and fb:app_id tags are missing. These tags are necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:title is missing. The og:title meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:type is missing. The og:type meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Like Button Tag Missing: og:image is missing. The og:image meta tag is necessary for Facebook to render a News Feed story that generates a high click-through rate.
Open Graph Warnings That Should Be Fixed
Inferred Property: The 'og:url' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:title' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:description' property should be explicitly provided, even if a value can be inferred from other tags.
Inferred Property: The 'og:image' property should be explicitly provided, even if a value can be inferred from other tags.
Object Properties
og:url: http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
og:type: website
og:title: #Page Title#
og:image:
og:description: #Meta Description#
og:updated_time: 1348134967
Redirect Path
originale: http://www.mydomain.com/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
rel="canonical": http://www.mydomain.com/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/threads/1-Hello-Community
Final URL is in bold (this is the URL we tried to extract metadata from).
Please, please, PLEASE... help me out!
You may need to add the meta og tag
<meta type="og:url" content="<?php get_current_url(); ?>" >
try it